Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

pipemod(7m) [sunos man page]

pipemod(7M)							  STREAMS Modules						       pipemod(7M)

NAME
pipemod - STREAMS pipe flushing module DESCRIPTION
The typical stream is composed of a stream head connected to modules and terminated by a driver. Some stream configurations such as pipes and FIFOs do not have a driver and hence certain features commonly supported by the driver need to be provided by other means. Flushing is one such feature, and it is provided by the pipemod module. Pipes and FIFOs in their simplest configurations only have stream heads. A write side is connected to a read side. This remains true when modules are pushed. The twist occurs at a point known as the mid-point. When an M_FLUSH message is passed from a write queue to a read queue the FLUSHR and/or FLUSHW bits have to be switched. The mid-point of a pipe is not always easily detectable, especially if there are numerous modules pushed on either end of the pipe. In that case there needs to be a mechanism to intercept all message passing through the stream. If the message is an M_FLUSH message and it is at the mid-point, the flush bits need to be switched. This bit switching is handled by the pipemod module. pipemod should be pushed onto a pipe or FIFO where flushing of any kind will take place. The pipemod module can be pushed on either end of the pipe. The only requirement is that it is pushed onto an end that previously did not have modules on it. That is, pipemod must be the first module pushed onto a pipe so that it is at the mid-point of the pipe itself. The pipemod module handles only M_FLUSH messages. All other messages are passed on to the next module using the putnext() utility routine. If an M_FLUSH message is passed to pipemod and the FLUSHR and FLUSHW bits are set, the message is not processed but is passed to the next module using the putnext() routine. If only the FLUSHR bit is set, the FLUSHR bit is turned off and the FLUSHW bit is set. The message is then passed on to the next module using putnext(). Similarly, if the FLUSHW bit is the only bit set in the M_FLUSH message, the FLUSHW bit is turned off and the FLUSHR bit is turned on. The message is then passed to the next module on the stream. The pipemod module can be pushed on any stream that desires the bit switching. It must be pushed onto a pipe or FIFO if any form of flush- ing must take place. SEE ALSO
STREAMS Programming Guide SunOS 5.10 21 Aug 1992 pipemod(7M)

Check Out this Related Man Page

qreply(9F)						   Kernel Functions for Drivers 						qreply(9F)

NAME
qreply - send a message on a stream in the reverse direction SYNOPSIS
#include <sys/stream.h> void qreply(queue_t *q, mblk_t *mp); INTERFACE LEVEL
Architecture independent level 1 (DDI/DKI). PARAMETERS
q Pointer to the queue. mp Pointer to the message to be sent in the opposite direction. DESCRIPTION
qreply() sends messages in the reverse direction of normal flow. That is, qreply(q, mp) is equivalent to putnext(OTHERQ(q), mp). CONTEXT
qreply() can be called from user or interrupt context. EXAMPLES
Example 1: Canonical Flushing Code for STREAMS Drivers. This example depicts the canonical flushing code for STREAMS drivers. Assume that the driver has service procedures so that there may be messages on its queues. See srv(9E). Its write-side put procedure handles M_FLUSH messages by first checking the FLUSHW bit in the first byte of the message, then the write queue is flushed (line 8) and the FLUSHW bit is turned off (line 9). See put(9E). If the FLUSHR bit is on, then the read queue is flushed (line 12) and the message is sent back up the read side of the stream with the qre- ply(9F) function (line 13). If the FLUSHR bit is off, then the message is freed (line 15). See the example for flushq(9F) for the canoni- cal flushing code for modules. 1 xxxwput(q, mp) 2 queue_t *q; 3 mblk_t *mp; 4 { 5 switch(mp->b_datap->db_type) { 6 case M_FLUSH: 7 if (*mp->b_rptr & FLUSHW) { 8 flushq(q, FLUSHALL); 9 *mp->b_rptr &= ~FLUSHW; 10 } 11 if (*mp->b_rptr & FLUSHR) { 12 flushq(RD(q), FLUSHALL); 13 qreply(q, mp); 14 } else { 15 freemsg(mp); 16 } 17 break; . . . 18 } 19 } SEE ALSO
put(9E), srv(9E), flushq(9F), OTHERQ(9F), putnext(9F) Writing Device Drivers STREAMS Programming Guide SunOS 5.10 11 Apr 1991 qreply(9F)
Man Page