Gets a message from a queue.
mblk_t *
getq(q)
register queue_t * q;
The getq utility gets the next available message from the queue pointed to by the q parameter. The getq utility returns a pointer to the message and removes that message from the queue. If no message is queued, the getq utility returns null.
The getq utility, and certain other utility routines, affect flow control in the Stream as follows: If the getq utility returns null, the queue is marked with the QWANTR flag so that the next time a message is placed on it, it will be scheduled for service (that is, enabled - see the qenable utility). If the data in the enqueued messages in the queue drops below the low-water mark, as specified by the q_lowat field, and if a queue behind the current queue has previously attempted to place a message in the queue and failed, (that is, was blocked - see the canput utility), then the queue behind the current queue is scheduled for service.
The queue count is maintained on a per-band basis. Priority band 0 (normal messages) uses the q_count and q_lowat fields. Nonzero priority bands use the fields in their respective qband structures (the qb_count and qb_lowat fields). All messages appear on the same list, linked according to their b_next pointers.
The q_count field does not reflect the size of all messages on the queue; it only reflects those messages in the normal band of flow.
This utility is part of STREAMS Kernel Extensions.
Item | Description |
---|---|
q | Specifies the queue from which to get the message. |
On successful completion, the getq utility returns a pointer to the message. Otherwise, it returns a null value.