2 .\" Copyright (c) 2003, Sun Microsystems, Inc., All Rights Reserved
3 .\" 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.
4 .\" 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.
5 .\" 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]
6 .TH QWAIT 9F "Dec 15, 2003"
8 qwait, qwait_sig \- STREAMS wait routines
12 #include <sys/stream.h>
17 \fBvoid\fR \fBqwait\fR(\fBqueue_t *\fR\fIq\fR);
22 \fBint\fR \fBqwait_sig\fR(\fBqueue_t *\fR\fIq\fR);
28 Solaris DDI specific (Solaris DDI).
36 Pointer to the queue that is being opened or closed.
42 \fBqwait()\fR and \fBqwait_sig()\fR are used to wait for a message to arrive to
43 the \fBput\fR(9E) or \fBsrv\fR(9E) procedures. \fBqwait()\fR and
44 \fBqwait_sig()\fR can also be used to wait for \fBqbufcall\fR(9F) or
45 \fBqtimeout\fR(9F) callback procedures to execute. These routines can be used
46 in the \fBopen\fR(9E) and \fBclose\fR(9E) procedures in a STREAMS driver or
50 The thread that calls \fBclose()\fR does not necessarily have the ability to
51 receive signals, particularly when called by \fBexit\fR(2). In this case,
52 \fBqwait_sig()\fR behaves exactly as \fBqwait()\fR. Driver writers may use
53 \fBddi_can_receive_sig\fR(9F) to determine when this is the case, and, if so,
54 arrange some means to avoid blocking indefinitely (for example, by using
58 \fBqwait()\fR and \fBqwait_sig()\fR atomically exit the inner and outer
59 perimeters associated with the queue, and wait for a thread to leave the
60 module's \fBput\fR(9E), \fBsrv\fR(9E), or \fBqbufcall\fR(9F) /
61 \fBqtimeout\fR(9F) callback procedures. Upon return they re-enter the inner and
65 This can be viewed as there being an implicit wakeup when a thread leaves a
66 \fBput\fR(9E) or \fBsrv\fR(9E) procedure or after a \fBqtimeout\fR(9F) or
67 \fBqbufcall\fR(9F) callback procedure has been run in the same perimeter.
70 \fBqprocson\fR(9F) must be called before calling \fBqwait()\fR or
74 \fBqwait()\fR is not interrupted by a signal, whereas \fBqwait_sig()\fR is
75 interrupted by a signal. \fBqwait_sig()\fR normally returns non-zero, and
76 returns zero when the waiting was interrupted by a signal.
79 \fBqwait()\fR and \fBqwait_sig()\fR are similar to \fBcv_wait()\fR and
80 \fBcv_wait_sig()\fR except that the mutex is replaced by the inner and outer
81 perimeters and the signalling is implicit when a thread leaves the inner
82 perimeter. See \fBcondvar\fR(9F).
90 For \fBqwait_sig()\fR, indicates that the condition was not necessarily
91 signaled, and the function returned because a signal was pending.
97 These functions can only be called from an \fBopen\fR(9E) or \fBclose\fR(9E)
101 \fBExample 1 \fRUsing \fBqwait()\fR
104 The open routine sends down a \fBT_INFO_REQ\fR message and waits for the
105 \fBT_INFO_ACK\fR. The arrival of the \fBT_INFO_ACK\fR is recorded by resetting
106 a flag in the unit structure (\fBWAIT_INFO_ACK\fR). The example assumes that
107 the module is \fBD_MTQPAIR\fR or \fBD_MTPERMOD\fR.
116 /* Allocate xxdata structure */
118 /* Format T_INFO_ACK in mp */
120 xx->xx_flags |= WAIT_INFO_ACK;
121 while (xx->xx_flags & WAIT_INFO_ACK)
129 struct xxdata *xx = (struct xxdata *)q->q_ptr;
134 if (xx->xx_flags & WAIT_INFO_ACK) {
135 /* Record information from info ack */
136 xx->xx_flags &= ~WAIT_INFO_ACK;
149 \fBclose\fR(9E), \fBopen\fR(9E), \fBput\fR(9E), \fBsrv\fR(9E),
150 \fBcondvar\fR(9F), \fBddi_can_receive_sig\fR(9F), \fBmt-streams\fR(9F),
151 \fBqbufcall\fR(9F), \fBqprocson\fR(9F), \fBqtimeout\fR(9F)
154 \fISTREAMS Programming Guide\fR
157 \fIWriting Device Drivers\fR