STREAMS/UX for the HP 9000 Reference Manual
153
Debugging STREAMS/UX Modules and Drivers
STREAMS/UX Debugging Tool
Example 2: Simple Driver Programming Error
In this example, the user has written a loopback driver, sp, which uses
timeout to simulate interrupts. sp's put routine calls timeout for each
message it receives. When the timeout expires, HP-UX calls sp's timeout
function. This function calls putq() to put the message on sp's read queue.
Figure 3 Stream Created By Opening Loopback (sp) Driver
The sp_put() routine puts the incoming message on a queue in sp's private
data structure before calling timeout(). sp's timeout function takes the first
message off the queue, and calls putq to put the message on sp's read queue.
sp's open routine saves a pointer to sp's private data structure in the write and
read queues' q_ptr field. sp's private data structure and the sp_put() and
sp_timeout() routines are shown below.
Read Queue
Write Queue
Read Queue
Write Queue
Stream Head
sp driver
timer pops &
timeout calls
sp_timeout,
which calls putq
sp_put sets
timeout
.
. later
.