STREAMS-UX Programmer's Guide (February 2007)
Messages
Message Structures
Chapter 3
47
Message Queues
Message queues are essentially a linked list of messages waiting to be processed by the service procedure. The
STREAMS scheduler accesses these lists through the pointers available to the head and tail of the lists in the
module or driver queues as explained.
A queue will generally not use its message queue if there is no service procedure associated with it. Message
queues grow as the processing of the messages on it are delayed due to a STREAMS scheduler being delayed,
or when the next module is flow-controlled. The priority of the message indicates the order in which it is
enqueued.
High priority messages are placed at the head of the message queue. Then, the priority band messages and
finally, band zero or ordinary messages as shown in Figure 3-2, “Message Ordering in a Queue.” The service
procedure processes the enqueued messages in a first-in first-out (FIFO) manner.
Figure 3-2 Message Ordering in a Queue
Queue
In addition to the pointers to the message queues, the message queue also contains the entry points for
message processing, flow control parameters, pointer to the next queue in the stream and so on.
Message queues are always allocated in pairs (read and write). One pair is allocated for each component of
the stream. A queue-pair is allocated for each streams component, and is initialized when the streams
component becomes a part of the stream. The queue pairs for the stream head and driver are allocated when
the driver is opened and deallocated on closing the driver. The queue pairs for a module are allocated upon
pushing the module on to the stream and deallocated on popping or removing it from the stream.
ordinary
band 0
messages
priority
band 1
messages
priority
band 2
messages
high
priority
messages
...
tail head