Xenomai API  2.6.5
File descriptors events multiplexing services.
Collaboration diagram for File descriptors events multiplexing services.:

Files

file  select.h
 file descriptors events multiplexing header.
 
file  select.c
 file descriptors events multiplexing.
 

Functions

void xnselect_init (struct xnselect *select_block)
 Initialize a struct xnselect structure. 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...
 
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...
 

Detailed Description

File descriptors events multiplexing services.

This module implements the services needed for implementing the posix "select" service, or any other events multiplexing services.

Following the implementation of the posix select service, this module defines three types of events:

It works by defining two structures:

Function Documentation

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.

Parameters
selectorstructure to check for pending events
out_fdsThe 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_fdsthe set of descriptors which events should be checked
nfdsthe highest-numbered descriptor in any of the in_fds sets, plus 1;
timeoutthe 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_modethe mode of timeout.
Return values
-EINVALif nfds is negative;
-ECHRNGif some of the descriptors passed in in_fds have not yet been registered with xnselect_bind(), out_fds contains the set of such descriptors;
-EINTRif xnselect was interrupted while waiting;
0in case of timeout.
thenumber of file descriptors having received an event.

References XNBREAK, xnsynch_sleep_on(), and XNTIMEO.

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.

Parameters
select_blockpointer to the struct xnselect to be bound;
bindingpointer to a newly allocated (using xnmalloc) struct xnselect_binding;
selectorpointer to the selector structure;
typetype of events (XNSELECT_READ, XNSELECT_WRITE, or XNSELECT_EXCEPT);
indexindex of the file descriptor (represented by select_block) in the bit fields used by the selector structure;
statecurrent 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.

Return values
-EINVALif type or index is invalid;
0otherwise.

References xnpod_schedule().

Referenced by rtdm_event_select_bind(), and rtdm_sem_select_bind().

void xnselect_destroy ( struct xnselect select_block)

Destroy the xnselect structure associated with a file descriptor.

Any binding with a xnselector block is destroyed.

Parameters
select_blockpointer to the xnselect structure associated with a file descriptor

References xnpod_schedule().

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().

Parameters
select_blockpointer to the xnselect structure to be initialized

Referenced by rtdm_event_init(), and rtdm_sem_init().

void xnselector_destroy ( struct xnselector *  selector)

Destroy a selector block.

All bindings with file descriptor are destroyed.

Parameters
selectorthe selector block to be destroyed

Referenced by xnpod_delete_thread().

int xnselector_init ( struct xnselector *  selector)

Initialize a selector structure.

Parameters
selectorThe selector structure to be initialized.
Return values
0

References xnsynch_init().