2 .\" Copyright 1989 AT&T
3 .\" Copyright (c) 2006, Sun Microsystems, Inc., All Rights Reserved
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 PUTNEXTCTL 9F "Jan 16, 2006"
9 putnextctl \- send a control message to a queue
13 #include <sys/stream.h>
17 \fBint\fR \fBputnextctl\fR(\fBqueue_t *\fR\fIq\fR, \fBint\fR \fItype\fR);
23 Architecture independent level 1 (DDI/DKI).
31 Queue to which the message is to be sent.
40 Message type (must be control, not data type).
46 The \fBputnextctl()\fR function tests the \fItype\fR argument to make sure a
47 data type has not been specified, and then attempts to allocate a message
48 block. \fBputnextctl()\fR fails if \fItype\fR is \fBM_DATA\fR, \fBM_PROTO\fR,
49 or \fBM_PCPROTO\fR, or if a message block cannot be allocated. If successful,
50 \fBputnextctl()\fR calls the \fBput\fR(9E) routine of the queue pointed to by
51 \fIq\fR with the newly allocated and initialized messages.
54 A call to \fBputnextctl(\fR\fIq\fR\fB,\fR\fItype\fR\fB)\fR is an atomic
55 equivalent of \fBputctl(\fR\fIq\fR\fB->q_next\fR,\fItype\fR\fI).\fR The STREAMS
56 framework provides whatever mutual exclusion is necessary to insure that
57 dereferencing \fIq\fR through its \fBq_next\fR field and then invoking
58 \fBputctl\fR(9F) proceeds without interference from other threads.
61 The \fBputnextctl()\fR function should always be used in preference to
66 On success, \fB1\fR is returned. If \fItype\fR is a data type, or if a message
67 block cannot be allocated, \fB0\fR is returned.
71 The \fBputnextctl()\fR function can be user, interrupt, or kernel context.
75 The \fBsend_ctl\fR routine is used to pass control messages downstream.
76 \fBM_BREAK\fR messages are handled with \fBputnextctl\fR(\|) (line 8).
77 \fBputnextctl1\fR(9F) (line 13) is used for \fBM_DELAY\fR messages, so that
78 \fIparm\fR can be used to specify the length of the delay. In either case, if a
79 message block cannot be allocated a variable recording the number of
80 allocation failures is incremented (lines 9, 14). If an invalid message type
81 is detected, \fBcmn_err\fR(9F) panics the system (line 18).
86 2 send_ctl(queue_t *wrq, uchar_t type, uchar_t parm)
88 4 extern int num_alloc_fail;
92 8 if (!putnextctl(wrq, M_BREAK))
97 13 if (!putnextctl1(wrq, M_DELAY, parm))
102 18 cmn_err(CE_PANIC, "send_ctl: bad message type passed");
112 \fBput\fR(9E), \fBcmn_err\fR(9F), \fBdatamsg\fR(9F), \fBputctl\fR(9F),
113 \fBputnextctl1\fR(9F)
116 \fIWriting Device Drivers\fR
119 \fISTREAMS Programming Guide\fR