STREAMS-UX Programmer's Guide (February 2007)

Messages
Message Structures
Chapter 3
50
The qinit Structure
The qinit structure contains the addresses of the functions associated with the queue, associated module
information, and an optional statistics if present. The streamtab structure as shown earlier for a module or
driver has pointers to the qinit structure both for the upstream and downstream processing. The struct
qinit is defined in <sys/stream.h> and contains the following fields:
int *qi_putp (queue_t *, mblk_t *); /* put procedure */
int *qi_srvp (queue_t *); /* service procedure */
int *qi_qopen (); /* open routine */
int *qi_qclose (); /* close routine */
int *qi_qadmin (void); /* admin procedure */
struct module_info * qi_minfo; /* module parameters */
struct module_stat * qi_mstat; /* module statistics */
qband Structure
The qband structure maintains information about each priority band in a queue. These qband structures are
not pre-allocated per queue. They are allocated when a message with a priority band value greater than zero
is placed on a queue. The maximum number of qband structures in a queue is 255. Once allocated, the qband
structure remains associated with the queue until the queue gets freed. The struct qband is defined in
<sys/stream.h> and contains the following fields:
struct qband * qb_next; /* next band for this queue */
ulong qb_count; /* weighted character count in band */
struct msgb * qb_first; /* head of message queue */
struct msgb * qb_last; /* tail of message queue */
ulong qb_hiwat; /* high water mark */
ulong qb_lowat; /* low water mark */
ulong qb_flag; /* state */
The qb_next field points to the next priority band in the queue. The qb_count field contains the total number
of bytes for all the messages in the band. The qb_first and qb_last fields point to the first and the last
message in the band. Each band also contains a separate high and low water mark, qb_hiwat and qb_lowat.
The qb_flag flag denotes the state of the band, represented by the following three values:
QB_WANTW Back enable the stream when this queue or band drains.
QB_BACK The queue is back enabled.
QB_FULL The queue is full.