Arm a resource manager
#include <unistd.h> #include <sys/iomsg.h> int ionotify ( int fd, int action, int flags, const struct sigevent *event );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The ionotify() function arms the resource manager associated with fd to send the event notification event. The event is sent when a condition specified by a combination of action and flags occurs. This function corresponds to the Linux epoll() function and BSD's kqueue().
The QNX Neutrino implementation of select() is built on top of ionotify(). Generally, you use ionotify() if you want to combine input from file descriptors with QNX Neutrino messaging in the same process. Use select() when you're handling multiple file descriptors from sockets, pipes, serial ports, and so on.
Flags
The flags argument specifies the types of conditions that can be checked for notification. Each resource manager maintains a different context for each notification condition. Only those notification bits specified are affected. In the following example, the second call to ionotify() doesn't affect the first, since it specifies a different notification:
ionotify( fd, _NOTIFY_ACTION_POLLARM, _NOTIFY_COND_INPUT, &event ); ionotify( fd, _NOTIFY_ACTION_POLLARM, _NOTIFY_COND_OUTPUT, &event );
The conditions specified by flags are:
The method for changing the default number for _NOTIFY_COND_OUTPUT and _NOTIFY_COND_INPUT depends on the device. For example, character special devices can call readcond().
For resource managers that support both an edited and raw mode, the mode should be set to raw to ensure proper operation of ionotify().
The above flags are located in the top bits of flags. They are defined by _NOTIFY_COND_MASK.
In the case of an asynchronous notification using the passed event, such as a QNX Neutrino pulse or queued realtime signal, the 32-bit value in event->sigev_value.sival_int is returned to you unmodified, unless you've selected the SI_NOTIFY code, in which case the top bits (defined by _NOTIFY_COND_MASK) are set to the active notifications. In this case, you should limit the sival_int to the mask defined by _NOTIFY_DATA_MASK.
For example, the POSIX select() function specifies SI_NOTIFY and uses the allowable data bits of sival_int as a serial number.
Actions
The action argument specifies the type of arming action to take. When a condition is armed, the resource manager monitors it and, when met, delivers event using MsgDeliverEvent(). When an event is delivered, it's always disarmed except where noted below.
Note that for transition arming (as specified by an action of _NOTIFY_ACTION_TRANARM, only one notification of that type can be outstanding per device. When the transition arm fires, it's removed.
Each action is designed to support a specific notification type as follows:
Returns active conditions as requested by flags.
Returns active conditions as requested by flags.
Since this arms for a transition, the return value is always zero.
You can use the _NOTIFY_ACTION_POLLARM or _NOTIFY_ACTION_POLL action to generate events that are level- as opposed to transition-oriented.
When an action is armed in a resource manager, it remains armed until one of the following occurs:
Active conditions as requested by flags. In the case of a transition action, a zero is returned. If an error occurs, -1 is returned (errno is set).
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |