1flushq(9F)               Kernel Functions for Drivers               flushq(9F)
2
3
4

NAME

6       flushq - remove messages from a queue
7

SYNOPSIS

9       #include <sys/stream.h>
10
11
12
13       void flushq(queue_t *q, int flag);
14
15

INTERFACE LEVEL

17       Architecture independent level 1 (DDI/DKI).
18

PARAMETERS

20       q       Pointer to the queue to be flushed.
21
22
23       flag    Valid flag values are:
24
25
26       FLUSHDATA    Flush only data messages (types M_DATA M_DELAY M_PROTO and
27                    M_PCPROTO).
28
29
30       FLUSHALL     Flush all messages.
31
32

DESCRIPTION

34       The flushq() function frees messages and their associated  data  strucā€
35       tures  by calling freemsg(9F). If the queue's count falls below the low
36       water mark and the queue was blocking an  upstream  service  procedure,
37       the nearest upstream service procedure is enabled.
38

CONTEXT

40       The  flushq()  function  can  be called from user, interrupt, or kernel
41       context.
42

EXAMPLES

44       Example 1 Using flushq()
45
46
47       This example depicts the canonical flushing code for  STREAMS  modules.
48       The  module  has a write service procedure and potentially has messages
49       on the queue. If it receives an M_FLUSH message, and if the FLUSHR  bit
50       is  on  in the first byte of the message (line 10), then the read queue
51       is flushed (line 11). If the FLUSHW bit is on (line 12), then the write
52       queue  is  flushed  (line  13). Then the message is passed along to the
53       next entity in the stream (line 14). See the example for qreply(9F) for
54       the canonical flushing code for drivers.
55
56
57               1  /*
58               2   * Module write-side put procedure.
59               3   */
60               4  xxxwput(q, mp)
61               5      queue_t *q;
62               6      mblk_t *mp;
63               7  {
64               8   switch(mp->b_datap->db_type) {
65               9      case M_FLUSH:
66              10        if (*mp->b_rptr & FLUSHR)
67              11             flushq(RD(q), FLUSHALL);
68              12        if (*mp->b_rptr & FLUSHW)
69              13             flushq(q, FLUSHALL);
70              14        putnext(q, mp);
71              15        break;
72                        . . .
73              16   }
74              17  }
75
76

SEE ALSO

78       flushband(9F), freemsg(9F), putq(9F), qreply(9F)
79
80
81       Writing Device Drivers STREAMS Programming Guide
82
83
84
85SunOS 5.11                        16 Jan 2006                       flushq(9F)
Impressum