RTEMS 5.2
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
aio_misc.h
Go to the documentation of this file.
1
9/*
10 * Copyright 2010, Alin Rus <alin.codejunkie@gmail.com>
11 *
12 * The license and distribution terms for this file may be
13 * found in the file LICENSE in this distribution or at
14 * http://www.rtems.org/license/LICENSE.
15 */
16
17#ifndef _AIO_MISC_H
18#define _AIO_MISC_H
19
20#include <stdio.h>
21#include <string.h>
22#include <aio.h>
23#include <pthread.h>
24#include <rtems.h>
25#include <rtems/chain.h>
26#include <rtems/seterr.h>
27
28#ifdef __cplusplus
29extern "C"
30{
31#endif
32
33 /* Actual request being processed */
34 typedef struct
35 {
36 rtems_chain_node next_prio; /* chain requests in order of priority */
37 int policy; /* If _POSIX_PRIORITIZED_IO and
38 _POSIX_PRIORITY_SCHEDULING are defined */
39 int priority; /* see above */
40 pthread_t caller_thread; /* used for notification */
41 struct aiocb *aiocbp; /* aio control block */
43
44 typedef struct
45 {
46 rtems_chain_node next_fd; /* order fd chains in queue */
47 rtems_chain_control perfd; /* chain of requests for this fd */
48 int fildes; /* file descriptor to be processed */
49 int new_fd; /* if this is a newly created chain */
50 pthread_mutex_t mutex;
51 pthread_cond_t cond;
52
54
55 typedef struct
56 {
57 pthread_mutex_t mutex;
58 pthread_cond_t new_req;
59 pthread_attr_t attr;
60
61 rtems_chain_control work_req; /* chains being worked by active threads */
62 rtems_chain_control idle_req; /* fd chains waiting to be processed */
63 unsigned int initialized; /* specific value if queue is initialized */
64 int active_threads; /* the number of active threads */
65 int idle_threads; /* number of idle threads */
66
68
69extern rtems_aio_queue aio_request_queue;
70
71#define AIO_QUEUE_INITIALIZED 0xB00B
72
73#ifndef AIO_MAX_THREADS
74#define AIO_MAX_THREADS 5
75#endif
76
77#ifndef AIO_MAX_QUEUE_SIZE
78#define AIO_MAX_QUEUE_SIZE 30
79#endif
80
81int rtems_aio_init (void);
82int rtems_aio_enqueue (rtems_aio_request *req);
83rtems_aio_request_chain *rtems_aio_search_fd
84(
86 int fildes,
87 int create
88);
89void rtems_aio_remove_fd (rtems_aio_request_chain *r_chain);
90int rtems_aio_remove_req (rtems_chain_control *chain,
91 struct aiocb *aiocbp);
92
93#ifdef RTEMS_DEBUG
94#include <assert.h>
95
96#define AIO_assert(_x) assert(_x)
97#define AIO_printf(_x) printf(_x)
98#else
99#define AIO_assert(_x)
100#define AIO_printf(_x)
101#endif
102
103#define rtems_aio_set_errno_return_minus_one( _error, _aiocbp ) \
104 do { (_aiocbp)->error_code = (_error); \
105 (_aiocbp)->return_value = -1; \
106 rtems_set_errno_and_return_minus_one (_error);} while(0)
107
108#ifdef __cplusplus
109}
110#endif
111
112#endif
POSIX Asynchronous Input and Output.
Information for the Assert Handler.
Chain API.
POSIX Threads Private Support.
Data which Ease the Burden of Consistently Setting Errno.
Definition: chain.h:68
Definition: mutex.h:4
Definition: aio_misc.h:56
Definition: aio_misc.h:45
Definition: aio_misc.h:35
Definition: chain.h:86