Подготовить менеджер ресурсов
#include <unistd.h>#include <sys/iomsg.h>int ionotify( int fd,int action,int flags,const struct sigevent *event );
NULL
to disarm a notification.libc
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.
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:
1
. For a character device such as 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. _NOTIFY_COND_INPUT
. _NOTIFY_COND_OUTPUT
. _NOTIFY_COND_OBAND
. 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 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 Unix select() function specifies SI_NOTIFY
and uses the allowable data bits of sival_int as a serial number.
![]() | 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. |
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:
_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. 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:
![]() | There's a limit of one notification per message queue or resource manager. If a notification was already armed for the specified resource, ionotify() indicates an error of EBUSY . |
Active conditions as requested by flags. In the case of a transition action, a zero is returned.
Если возникла ошибка функция возвращает -1
, код ошибки записывается в errno.
ЗОСРВ «Нейтрино»
mq_notify(), select(), struct sigevent
Предыдущий раздел: Описание API системной библиотеки