Writing Monitors for the Event Monitoring Service (December 1999)

Chapter 3 129
Creating a Resource Monitor
Defining an Internal Timeout
Defining an Internal Timeout
Use an internal timeout to indicate that the time interval specified by
the resource monitor has expired without any messages arriving. This
event applies only to resource monitors that use the select(2)
parameters. Its purpose is to allow a status check that is not bound by
the EMS request timing limits.
The way the RM_SELECT_EVENT and RM_TIMEOUT_EVENT events are
handled by the resource monitor is dependent on their implementation.
Use the same methods you use for standard select(2) events.
Sample Code
/*****************************************************************************/
/* NAME: ems_wait_for_request */
/*****************************************************************************/
/* */
/* PURPOSE: Perform the EMS communication functions of a resource monitor. */
/* Once registration is complete and the polling interval timeout */
/* is set we turn over control to EMS and wait for one of the */
/* following: */
/* 1. A client requesting monitor information: */
/* RM_SUBCLASS_REQUEST_EVENT, RM_MONITOR_REQUEST_EVENT, */
/* RM_RESOURCE_UPDATE_EVENT */
/* 2. A timeout indicating a device needs polled: */
/* RM_TIMEOUT_EVENT */
/* 3. Data is available on one of the registered file descriptors: */
/* RM_SELECT_EVENT */
/* For items 2 and 3 above, we exit requiring the monitor */
/* developer to implement the necessary functionality to poll */
/* the device or read the data pipe. */
/* INPUTS: Input parameters - */
/* status: place holder for exit status */
/* OUTPUTS: Output parameters - */
/* status can be one of the following: */
/* EMS_FD_READY Data is available in the registered pipe */
/* EMS_TIMEOUT The polling interval as expired */
/* EMS_SCREPLY A subclass reply requiring a hw scan has occured */
/* EMS_ERROR An internal EMS error occured */
/* */
/*****************************************************************************/