Kernel Functions for Drivers qwait(9F)
NAME
qwait, qwaitsig - STREAMS wait routines
SYNOPSIS
#include
#include
void qwait(queuet *q);
int qwaitsig(queuet *q);
INTERFACE LEVEL
Solaris DI specific (Solaris DI).
PARAMETERS
qp Pointer to the queue that is being opened or closed.
DESCRIPTION
qwait() and qwaitsig() are used to wait for a message to
arrive to the put(9E) or srv(9E) procedures. qwait() and
qwaitsig() can also be used to wait for qbufcall(9F) or
qtimeout(9F) callback procedures to execute. These routines
can be used in the open(9E) and close(9E) procedures in a
STREAMS driver or module.
The thread that calls close() does not necessarily have the
ability to receive signals, particularly when called by
exit(2). In this case, qwaitsig() behaves exactly as
qwait(). Driver writers may use ddicanreceivesig(9F) to
determine when this is the case, and, if so, arrange some
means to avoid blocking indefinitely (for example, by using
qtimeout(9F).
qwait() and qwaitsig() atomically exit the inner and outer
perimeters associated with the queue, and wait for a thread
to leave the module's put(9E), srv(9E), or qbufcall(9F) /
qtimeout(9F) callback procedures. Upon return they re-enter
the inner and outer perimeters.
This can be viewed as there being an implicit wakeup when a
thread leaves a put(9E) or srv(9E) procedure or after a
qtimeout(9F) or qbufcall(9F) callback procedure has been run
in the same perimeter.
SunOS 5.11 Last change: 15 Dec 2003 1
Kernel Functions for Drivers qwait(9F)
qprocson(9F) must be called before calling qwait() or
qwaitsig().
qwait() is not interrupted by a signal, whereas qwaitsig()
is interrupted by a signal. qwaitsig() normally returns
non-zero, and returns zero when the waiting was interrupted
by a signal.
qwait() and qwaitsig() are similar to cvwait() and
cvwaitsig() except that the mutex is replaced by the inner
and outer perimeters and the signalling is implicit when a
thread leaves the inner perimeter. See condvar(9F).
RETURN VALUES
0 For qwaitsig(), indicates that the condition was not
necessarily signaled, and the function returned because
a signal was pending.
CONTEXT
These functions can only be called from an open(9E) or
close(9E) routine.
EXAMPLES
Example 1 Using qwait()
The open routine sends down a TINFOREQ message and waits
for the TINFOACK. The arrival of the TINFOACK is
recorded by resetting a flag in the unit structure
(WAITINFOACK). The example assumes that the module is
DMTQPAIR or DMTPERMOD.
xxopen(qp, ...)
queuet *qp;
{
struct xxdata *xx;
/* Allocate xxdata structure */
qprocson(qp);
/* Format TINFOACK in mp */
putnext(qp, mp);
xx->xxflags = WAITINFOACK;
while (xx->xxflags & WAITINFOACK)
qwait(qp);
return (0);
}
xxrput(qp, mp)
queuet *qp;
mblkt *mp;
SunOS 5.11 Last change: 15 Dec 2003 2
Kernel Functions for Drivers qwait(9F)
{
struct xxdata *xx = (struct xxdata *)q->qptr;
...
case TINFOACK:
if (xx->xxflags & WAITINFOACK) {
/* Record information from info ack */
xx->xxflags &= ~WAITINFOACK;
freemsg(mp);
return;
}
...
}
SEE ALSO
close(9E), open(9E), put(9E), srv(9E), condvar(9F),
ddicanreceivesig(9F), mt-streams(9F), qbufcall(9F),
qprocson(9F), qtimeout(9F)
STREAMS Programming Guide
Writing Device Drivers
SunOS 5.11 Last change: 15 Dec 2003 3
|