[Previous] [Contents] [Next]

ionotify()

Arm a resource manager

Synopsis:

#include <unistd.h>
#include <sys/iomsg.h>

int ionotify ( int fd,
               int action, 
               int flags, 
               const struct sigevent* event );

Library:

libc

Description:

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. Passing NULL for the event can be used to disarm a notification.

The flags argument specifies three 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:

_NOTIFY_COND_OBAND
Out-of-band data is available. The definition of out-of-band data is resource manager specific.
_NOTIFY_COND_OUTPUT
There's room in the output buffer for more data. The amount of room available needed to satisfy this condition is resource manager specific. Some resource managers may default to an empty output buffer while others may choose some percentage of the buffer empty.
_NOTIFY_COND_INPUT
There's input data available. The amount of data available defaults to 1. For a character device like a serial port this would be a character. For a POSIX message queue it would be a message. Each resource manager selects an appropriate object.

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.

The event argument points to a structure of type sigevent.

In the case of an asynchronous notification using the passed event, such as a QNX 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 Unix select() function specifies SI_NOTIFY and uses the allowable data bits of sival_int as a serial number.


Note: If you're using the SI_NOTIFY code, then you should clear the bits as specified by _NOTIFY_COND_MASK in the sigev_value field -- the resource manager only ever ORs in a value, it never clears the bits.

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:

_NOTIFY_ACTION_POLL
This action does a poll of the notification conditions specified by flags. It never arms an event, and it cancels all other asynchronous event notifications set up by a previous call to ionotify(). This also allows it to be used as a simple "disarm" call.

Returns active conditions as requested by flags.

_NOTIFY_ACTION_POLLARM
This action does a poll in the same way as _NOTIFY_ACTION_POLL. However, if none of the conditions specified in flags are present then each condition specified in flags is armed. If any condition is met, none of the conditions are armed. The Unix select() function uses ionotify() with this action.

Returns active conditions as requested by flags.

_NOTIFY_ACTION_TRANARM
This action arms for transitions of the notification conditions specified by flags. A transition is defined as a data transition from empty to nonempty on input. Its use on output isn't defined. Note that if there is data available when this call is used, a data transition won't occur. To generate an event using this type of notification you must arm the event and then drain the input using a nonblocking read. After this point, new input data cause the event to be delivered. The mq_notify() function uses ionotify() with this action.

Since this arms for a transition, the return value is always zero.

The _NOTIFY_ACTION_POLLARM or _NOTIFY_ACTION_POLL action can be used to generate events that are level as opposed to transition oriented.

When an action is armed in a resource manager, it remains armed until:

Returns:

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

Errors:

EBADF
The connection indicated by fd doesn't exist, or fd is no longer connected to a channel.
EFAULT
A fault occurred when the kernel tried to access the buffers provided. This may have occurred on the receive or the reply.
EINTR
The call was interrupted by a signal.
ENOMEM
The resource manager couldn't allocate a notify entry to save the request.
ENOSYS
The requested action isn't supported by this resource manager.
ESRVRFAULT
A fault occurred in a server's address space while accessing the server's message buffers. This may have occurred on the receive or the reply.
ETIMEDOUT
A kernel timeout unblocked the call. See TimerTimeout().

Classification:

QNX 6

Safety:
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

sigevent


[Previous] [Contents] [Next]