Writing Device Drivers for Oracle® Solaris 11.2

Exit Print View

Updated: September 2014
 
 

Introduction to Events

An event is a message that a device driver sends to interested entities to indicate that a change of state has taken place. Events are implemented in the Oracle Solaris OS as user-defined, name-value pair structures that are managed using the nvlist* functions. (See the nvlist_alloc(9F) man page. Events are organized by vendor, class, and subclass. For example, you could define a class for monitoring environmental conditions. An environmental class could have subclasses to indicate changes in temperature, fan status, and power.

When a change in state occurs, the device notifies the driver. The driver then uses the ddi_log_sysevent(9F) function to log this event in a queue called sysevent. The sysevent queue passes events to the user level for handling by either the syseventd daemon or syseventconfd daemon. These daemons send notifications to any applications that have subscribed for notification of the specified event.

Two methods for designers of user-level applications deal with events:

  • An application can use the routines in libsysevent(3LIB) to subscribe with the syseventd daemon for notification when a specific event occurs.

  • A developer can write a separate user-level application to respond to an event. This type of application needs to be registered with syseventadm(1M). When syseventconfd encounters the specified event, the application is run and deals with the event accordingly.

This process is illustrated in the following figure.

Figure 5-1  Event Plumbing

image:Diagram shows how events are logged into the sysevent queue for notification of user-level applications.