Even on a well-designed system, general system delays, malfunctions, and excessive accumulation on one or more streams can cause the message buffer pools to become depleted. Additionally, processing bursts can arise when a service procedure in one module has a long message queue and processes all its messages in one pass. STREAMS provides an independent mechanism to guard its message buffer pools from being depleted and to minimize long processing bursts at any one module.
Note: Flow control is applied only to normal priority messages.
The flow control mechanism is local to each stream and is advisory (voluntary), and it limits the number of characters that can be queued for processing at any QUEUE in a stream. This mechanism limits the buffers and related processing at any one QUEUE and in any one stream, but does not consider buffer pool levels or buffer usage in other streams.
The advisory mechanism operates between the two nearest QUEUEs in a stream containing service procedures. Messages are generally held on a message queue only if a service procedure is present in the associated QUEUE.
Messages accumulate at a QUEUE when its service procedure processing does not keep pace with the message arrival rate, or when the procedure is blocked from placing its messages on the following stream component by the flow-control mechanism. Pushable modules contain independent upstream and downstream limits, which are set when a developer specifies high-water and low-water control values for the QUEUE. The stream head contains a preset upstream limit (which can be modified by a special message sent from downstream) and a driver may contain a downstream limit.
STREAMS flow control operates in the following order:
Figure 10-3. Flow Control. This diagram shows queue B, queue C, and queue D side-by-side. Beside each queue is an arrow coming from the left pointing toward that queue, then another arrow leaving that queue and pointing to the queue on the right. There are dashed arrows leading down from queue B and queue D to message queues.
To use flow control, a developer need only call the utility that tests if a full condition exists ahead (for example, the canput utility), and perform some housekeeping if it does. Everything else is automatically handled by STREAMS.
See "STREAMS Messages" for more information about the STREAMS message-passing scheme.