1502 Remove conversion cruft from manpages
[unleashed.git] / usr / src / man / man9f / insq.9f
blobc11b3745d3909aeb715dba404d6ed79f4993c52e
1 '\" te
2 .\" Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved.
3 .\" Copyright 1989 AT&T
4 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
5 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
6 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
7 .TH INSQ 9F "Mar 23, 2009"
8 .SH NAME
9 insq \- insert a message into a queue
10 .SH SYNOPSIS
11 .LP
12 .nf
13 #include <sys/stream.h>
17 \fBint\fR \fBinsq\fR(\fBqueue_t *\fR\fIq\fR, \fBmblk_t *\fR\fIemp\fR, \fBmblk_t *\fR\fInmp\fR);
18 .fi
20 .SH INTERFACE LEVEL
21 .sp
22 .LP
23 Architecture independent level 1 (DDI/DKI).
24 .SH PARAMETERS
25 .sp
26 .ne 2
27 .na
28 \fB\fIq\fR\fR
29 .ad
30 .RS 7n
31 Pointer to the queue containing message \fIemp\fR.
32 .RE
34 .sp
35 .ne 2
36 .na
37 \fB\fIemp\fR\fR
38 .ad
39 .RS 7n
40 Enqueued message before which the new message is to be inserted. \fBmblk_t\fR
41 is an instance of the \fBmsgb\fR(9S) structure.
42 .RE
44 .sp
45 .ne 2
46 .na
47 \fB\fInmp\fR\fR
48 .ad
49 .RS 7n
50 Message to be inserted.
51 .RE
53 .SH DESCRIPTION
54 .sp
55 .LP
56 The \fBinsq()\fR function inserts a message into a queue. The message to be
57 inserted, \fInmp\fR, is placed in \fIq\fR immediately before the message
58 \fIemp\fR. If \fIemp\fR is \fINULL\fR, the new message is placed at the end of
59 the queue. The queue class of the new message is ignored. All flow control
60 parameters are updated. The service procedure is enabled unless \fBQNOENB\fR is
61 set.
62 .SH RETURN VALUES
63 .sp
64 .LP
65 The \fBinsq()\fR function returns \fB1\fR on success, and \fB0\fR on failure.
66 .SH CONTEXT
67 .sp
68 .LP
69 The \fBinsq()\fR function can be called from user, interrupt, or kernel
70 context.
71 .SH EXAMPLES
72 .sp
73 .LP
74 This routine illustrates the steps a transport provider may take to place
75 expedited data ahead of normal data on a queue (assume all \fBM_DATA\fR
76 messages are converted into \fBM_PROTO T_DATA_REQ\fR messages). Normal
77 \fBT_DATA_REQ\fR messages are just placed on the end of the queue (line 16).
78 However, expedited \fBT_EXDATA_REQ\fR messages are inserted before any normal
79 messages already on the queue (line 25). If there are no normal messages on the
80 queue, \fBbp\fR will be \fINULL\fR and we fall out of the \fBfor\fR loop (line
81 21). \fBinsq\fR acts like \fBputq\fR(9F) in this case.
82 .sp
83 .in +2
84 .nf
85  1  #include <sys/stream.h>
86  2  #include <sys/tihdr.h>
87  3
88  4  static int
89  5  xxxwput(queue_t *q, mblk_t *mp)
90  6  {
91  7   union T_primitives *tp;
92  8   mblk_t *bp;
93  9   union T_primitives *ntp;
95 11   switch (mp->b_datap->db_type) {
96 12   case M_PROTO:
97 13        tp = (union T_primitives *)mp->b_rptr;
98 14        switch (tp->type) {
99 15        case T_DATA_REQ:
100 16                putq(q, mp);
101 17                break;
103 19        case T_EXDATA_REQ:
104 20              /* Insert code here to protect queue and message block */
105 21               for (bp = q->q_first; bp; bp = bp->b_next) {
106 22                  if (bp->b_datap->db_type == M_PROTO) {
107 23                    ntp = (union T_primitives *)bp->b_rptr;
108 24                    if (ntp->type != T_EXDATA_REQ)
109 25                        break;
110 26                 }
111 27               }
112 28               (void)insq(q, bp, mp);
113 29               /* End of region that must be protected */
114 30               break;
115           . . .
116 31              }
117 32    }
118 33   }
120 .in -2
124 When using \fBinsq()\fR, you must ensure that the queue and the message block
125 is not modified by another thread at the same time. You can achieve this either
126 by using STREAMS functions or by implementing your own locking.
127 .SH SEE ALSO
130 \fBputq\fR(9F), \fBrmvq\fR(9F), \fBmsgb\fR(9S)
133 \fIWriting Device Drivers\fR
136 \fISTREAMS Programming Guide\fR
137 .SH WARNINGS
140 If \fIemp\fR is non-\fINULL\fR, it must point to a message on \fIq\fR or a
141 system panic could result.