Xenomai
3.1
|
This module implements the services needed for implementing the POSIX select() service, or any other event multiplexing services. More...
Functions | |
void | xnselect_init (struct xnselect *select_block) |
Initialize a struct xnselect structure. More... | |
static int | xnselect_signal (struct xnselect *select_block, unsigned int state) |
Signal a file descriptor state change. More... | |
void | xnselect_destroy (struct xnselect *select_block) |
Destroy the xnselect structure associated with a file descriptor. More... | |
int | xnselector_init (struct xnselector *selector) |
Initialize a selector structure. More... | |
int | xnselect (struct xnselector *selector, fd_set *out_fds[XNSELECT_MAX_TYPES], fd_set *in_fds[XNSELECT_MAX_TYPES], int nfds, xnticks_t timeout, xntmode_t timeout_mode) |
Check the state of a number of file descriptors, wait for a state change if no descriptor is ready. More... | |
void | xnselector_destroy (struct xnselector *selector) |
Destroy a selector block. More... | |
int | xnselect_bind (struct xnselect *select_block, struct xnselect_binding *binding, struct xnselector *selector, unsigned type, unsigned index, unsigned state) |
Bind a file descriptor (represented by its xnselect structure) to a selector block. More... | |
This module implements the services needed for implementing the POSIX select() service, or any other event multiplexing services.
Following the implementation of the posix select service, this module defines three types of events:
It works by defining two structures:
int xnselect | ( | struct xnselector * | selector, |
fd_set * | out_fds[XNSELECT_MAX_TYPES], | ||
fd_set * | in_fds[XNSELECT_MAX_TYPES], | ||
int | nfds, | ||
xnticks_t | timeout, | ||
xntmode_t | timeout_mode | ||
) |
Check the state of a number of file descriptors, wait for a state change if no descriptor is ready.
selector | structure to check for pending events |
out_fds | The set of descriptors with pending events if a strictly positive number is returned, or the set of descriptors not yet bound if -ECHRNG is returned; |
in_fds | the set of descriptors which events should be checked |
nfds | the highest-numbered descriptor in any of the in_fds sets, plus 1; |
timeout | the timeout, whose meaning depends on timeout_mode, note that xnselect() pass timeout and timeout_mode unchanged to xnsynch_sleep_on, so passing a relative value different from XN_INFINITE as a timeout with timeout_mode set to XN_RELATIVE, will cause a longer sleep than expected if the sleep is interrupted. |
timeout_mode | the mode of timeout. |
-EINVAL | if nfds is negative; |
-ECHRNG | if some of the descriptors passed in in_fds have not yet been registered with xnselect_bind(), out_fds contains the set of such descriptors; |
-EINTR | if xnselect was interrupted while waiting; |
0 | in case of timeout. |
the | number of file descriptors having received an event. |
int xnselect_bind | ( | struct xnselect * | select_block, |
struct xnselect_binding * | binding, | ||
struct xnselector * | selector, | ||
unsigned | type, | ||
unsigned | index, | ||
unsigned | state | ||
) |
Bind a file descriptor (represented by its xnselect structure) to a selector block.
select_block | pointer to the struct xnselect to be bound; |
binding | pointer to a newly allocated (using xnmalloc) struct xnselect_binding; |
selector | pointer to the selector structure; |
type | type of events (XNSELECT_READ, XNSELECT_WRITE, or XNSELECT_EXCEPT); |
index | index of the file descriptor (represented by select_block) in the bit fields used by the selector structure; |
state | current state of the file descriptor. |
select_block must have been initialized with xnselect_init(), the xnselector structure must have been initialized with xnselector_init(), binding may be uninitialized.
This service must be called with nklock locked, irqs off. For this reason, the binding parameter must have been allocated by the caller outside the locking section.
-EINVAL | if type or index is invalid; |
0 | otherwise. |
void xnselect_destroy | ( | struct xnselect * | select_block | ) |
Destroy the xnselect structure associated with a file descriptor.
Any binding with a xnselector block is destroyed.
select_block | pointer to the xnselect structure associated with a file descriptor |
void xnselect_init | ( | struct xnselect * | select_block | ) |
Initialize a struct xnselect structure.
This service must be called to initialize a struct xnselect structure before it is bound to a selector by the means of xnselect_bind().
select_block | pointer to the xnselect structure to be initialized |
|
inlinestatic |
Signal a file descriptor state change.
select_block | pointer to an xnselect structure representing the file descriptor whose state changed; |
state | new value of the state. |
1 | if rescheduling is needed; |
0 | otherwise. |
void xnselector_destroy | ( | struct xnselector * | selector | ) |
Destroy a selector block.
All bindings with file descriptor are destroyed.
selector | the selector block to be destroyed |
int xnselector_init | ( | struct xnselector * | selector | ) |
Initialize a selector structure.
selector | The selector structure to be initialized. |
0 |