STREAMS-UX Programmer's Guide (February 2007)

Modules and Drivers
Entry Points
Chapter 4
81
The return value from the service procedure is ignored.
A service procedure is scheduled to run by placing a message on its queue. When a service procedure is
executed by the scheduler, it should process all the messages on its queue. If it cannot process all the
messages, then it must ensure that it gets rescheduled so that the remaining messages are processed. One of
the rescheduling mechanisms provided by streams is flow-control, where the service procedure is
back-enabled if the queue to which it wants to send the message is flow-controlled. In this scenario, the
service procedure cannot empty its queue due to flow-control condition and needs to put the message back on
its queue and need not worry about rescheduling as the flow-control back enabling mechanism would enable
the service procedure when the flow-control conditions are removed.
For various other reasons where the service procedure cannot process all the messages from its queue,
bufcall and timeouts can be used for rescheduling the service procedure.
The rules that apply to put procedure for sleeping and unknown message types (including IOCTL commands)
also apply to service procedures. In addition service procedures must never place high-priority messages back
on their queues. This will result in infinite loop because when a high-priority message is placed on a queue its
service procedure is scheduled.
Interrupt Service Routine
STREAMS drivers associated with real hardware device, should specify a interrupt service routine entry
point for handling interrupts like regular device drivers. Drivers should specify their interrupt handler
routine in the wsio_intr_alloc() routine which is executed in
drv
_attach() or
drv
_if_init() routine.
See the HP-UX Driver Development Guide for more details on driver interrupt handling.
The interrupt service procedure has the following interface:
int drv_isr (long arg1);
Drivers are usually replaced with the driver’s name and arg1 is the argument passed in the
wsio_intr_alloc() routine along with driver’s interrupt service procedure name.
Since, the interrupt service procedure is executed in interrupt context and does not have any user context
associated with it, it should not call sleep() or any routines that would block. Interrupts service routines are
called with processor priority level elevated and they block interrupts at same or lower level interrupts. The
processing in these routines should be minimal to decrease the performance degradation that can occur due to
blocking of other interrupts.