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

NAME

6       rmvq - remove a message from a queue
7

SYNOPSIS

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

INTERFACE LEVEL

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

PARAMETERS

20       q     Queue containing the message to be removed.
21
22
23       mp    Message to remove.
24
25

DESCRIPTION

27       The  rmvq()  function  removes a message from a queue. A message can be
28       removed from anywhere on a queue. To prevent modules and  drivers  from
29       having to deal with the internals of message linkage on a queue, either
30       rmvq() or getq(9F) should be used to remove a message from a queue.
31

CONTEXT

33       The rmvq() function can be called from user, interrupt, or kernel  con‐
34       text.
35

EXAMPLES

37       This  code  fragment  illustrates how one may flush one type of message
38       from a queue. In  this  case,  only  M_PROTO  T_DATA_IND  messages  are
39       flushed.  For  each  message  on the queue, if it is an M_PROTO message
40       (line 8) of type T_DATA_IND (line 10), save a pointer to the next  mes‐
41       sage  (line  11),  remove  the T_DATA_IND message (line 12) and free it
42       (line 13). Continue with the next message in the list (line 19).
43
44         1  mblk_t *mp, *nmp;
45         2  queue_t *q;
46         3  union T_primitives *tp;
47         4
48         5    /* Insert code here to protect queue and message block */
49         6    mp = q->q_first;
50         7    while (mp) {
51         8         if (mp->b_datap->db_type == M_PROTO) {
52         9              tp = (union T_primitives *)mp->b_rptr;
53         10             if (tp->type == T_DATA_IND) {
54         11                  nmp = mp->b_next;
55         12                  rmvq(q, mp);
56         13                  freemsg(mp);
57         14                  mp = nmp;
58         15             } else {
59         16                  mp = mp->b_next;
60         17             }
61         18        } else {
62         19             mp = mp->b_next;
63         20        }
64         21   }
65         22   /* End of region that must be protected */
66
67
68
69       When using rmvq(), you must ensure that the queue and the message block
70       is  not  modified  by  another thread at the same time. You can achieve
71       this either by using STREAMS functions  or  by  implementing  your  own
72       locking.
73

SEE ALSO

75       freemsg(9F), getq(9F), insq(9F)
76
77
78       Writing Device Drivers
79
80
81       STREAMS Programming Guide
82

WARNINGS

84       Make sure that the message mp is linked onto q to avoid a possible sys‐
85       tem panic.
86
87
88
89SunOS 5.11                        16 Jan 2006                         rmvq(9F)
Impressum