canput(D3DK) —
.IX \f4canput\fP(D3DK)
.IX STREAMS message queues
.IX message (STREAMS)
NAME
canput − test for room in a message queue
SYNOPSIS
#include <sys/stream.h>
int canput(queue_t ∗q);
ARGUMENTS
qPointer to the message queue.
DESCRIPTION
canput tests if there is room for a message in the queue pointed to by q. The queue must have a service procedure.
It is possible because of race conditions to test for room using canput and get an indication that there is room for a message, and then have the queue fill up before subsequently enqueuing the message, causing a violation of flow control. This is not a problem, since the violation of flow control in this case is bounded.
RETURN VALUE
canput returns 1 if a message can be placed on the queue. 0 is returned if a message cannot be enqueued because of flow control.
LEVEL
Base or Interrupt.
NOTES
Does not sleep.
The driver is responsible for both testing a queue with canput and refraining from placing a message on the queue if canput fails. Driver-defined basic locks, read/write locks, and sleep locks may be held across calls to this function.
The q argument may not reference q_next (for example, an argument of q->q_next is erroneous on a multiprocessor and is disallowed by the DDI/DKI). canputnext(q) is provided as a multiprocessor-safe equivalent to the common call canput(q->q_next), which is no longer allowed [see canputnext(D3DK)].
SEE ALSO
bcanput(D3DK), bcanputnext(D3DK), canputnext(D3DK), putbq(D3DK), putnext(D3DK)
DDI/DKI — STREAMS