RTEMS: cpukit/include/rtems/posix/aio_misc.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
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 */
42 } rtems_aio_request;
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
53 } rtems_aio_request_chain;
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
67 } rtems_aio_queue;
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);
83 rtems_aio_request_chain *rtems_aio_search_fd
84(
85 rtems_chain_control *chain,
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
aio.h
POSIX Asynchronous Input and Output.
assert.h
Information for the Assert Handler.
chain.h
Chain API.
pthread.h
POSIX Threads Private Support.
rtems.h
seterr.h
Data which Ease the Burden of Consistently Setting Errno.
Chain_Node_struct
Definition: chain.h:68
mutex
Definition: mutex.h:4
rtems_aio_queue
Definition: aio_misc.h:56
rtems_aio_request_chain
Definition: aio_misc.h:45
rtems_aio_request
Definition: aio_misc.h:35
Chain_Control
Definition: chain.h:86