Kernel Functions for Drivers rmvq(9F)
NAME
rmvq - remove a message from a queue
SYNOPSIS
#include
void rmvq(queuet *q, mblkt *mp);
INTERFACE LEVEL
Architecture independent level 1 (DI/DKI).
PARAMETERS
q Queue containing the message to be removed.
mp Message to remove.
DESCRIPTION
The rmvq() function removes a message from a queue. A mes-
sage can be removed from anywhere on a queue. To prevent
modules and drivers from having to deal with the internals
of message linkage on a queue, either rmvq() or getq(9F)
should be used to remove a message from a queue.
CONTEXT
The rmvq() function can be called from user, interrupt, or
kernel context.
EXAMPLES
This code fragment illustrates how one may flush one type of
message from a queue. In this case, only MPROTO TDATAIND
messages are flushed. For each message on the queue, if it
is an MPROTO message (line 8) of type TDATAIND (line 10),
save a pointer to the next message (line 11), remove the
TDATAIND message (line 12) and free it (line 13). Continue
with the next message in the list (line 19).
1 mblkt *mp, *nmp;
2 queuet *q;
3 union Tprimitives *tp;
4
5 /* Insert code here to protect queue and message block */
6 mp = q->qfirst;
7 while (mp) {
8 if (mp->bdatap->dbtype == MPROTO) {
9 tp = (union Tprimitives *)mp->brptr;
10 if (tp->type == TDATAIND) {
11 nmp = mp->bnext;
SunOS 5.11 Last change: 16 Jan 2006 1
Kernel Functions for Drivers rmvq(9F)
12 rmvq(q, mp);
13 freemsg(mp);
14 mp = nmp;
15 } else {
16 mp = mp->bnext;
17 }
18 } else {
19 mp = mp->bnext;
20 }
21 }
22 /* End of region that must be protected */
When using rmvq(), you must ensure that the queue and the
message block is not modified by another thread at the same
time. You can achieve this either by using STREAMS functions
or by implementing your own locking.
SEE ALSO
freemsg(9F), getq(9F), insq(9F)
Writing Device Drivers
STREAMS Programming Guide
WARNINGS
Make sure that the message mp is linked onto q to avoid a
possible system panic.
SunOS 5.11 Last change: 16 Jan 2006 2
|