|
|
A STREAMS queue is an interface between a STREAMS driver or module and the rest of the Stream. Queues are always allocated as an adjacent pair. The queue with the lower address in the pair is a read queue, and the queue with the higher address is the write queue.
A queue's srv(D2str) service routine is invoked to process messages on the queue. It usually removes successive messages from the queue, processes them, and calls the put(D2str) routine of the next module in the Stream to give the processed message to the next queue.
A queue's put( ) routine is invoked by the preceding queue's put( ) and/or srv( ) routine to add a message to the current queue. If a module does not need to enqueue messages, its put( ) routine can call the neighboring queue's put( ) routine.
Each queue also has a pointer to an open(D2str) and close(D2str) routine. The open( ) routine of a driver is called when the driver is first opened and on every successive open of the Stream. The driver's close( ) routine is called when the last reference to the Stream is given up and the Stream is dismantled. The open( ) routine of a module is called when the module is first pushed on the Stream and on every successive open of the Stream. The close( ) routine of the module is called when the module is popped (removed) off the Stream.