DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
SVR5

putnextctl(D3str)


putnextctl -- send a control message to a queue

Synopsis (Not in ODDI)

   #include <sys/stream.h>
   #include <sys/ddi.h>
   

int putnextctl(queue_t *q, int type);

Description

putnextctl tests the type argument to make sure a data type has not been specified, and then attempts to allocate a message block. putnextctl fails if type is M_DATA, M_PROTO, or M_PCPROTO, or if a message block cannot be allocated. If successful, putnextctl calls the put(D2str) procedure of the queue pointed to by ``q->q_next'', passing it the allocated message.

Arguments


q
Pointer to the queue from which the message is to be sent.

type
Message type (must be a control type).

Return values

Upon successful completion, putnextctl returns 1. If type is a data type, or if a message block cannot be allocated, 0 is returned.

Usage

In multithreaded DDI drivers, the q argument to putctl(D3str) and putnextctl may not reference q_next (for example, an argument of q->q_next is erroneous in a multithreaded driver and is disallowed by the DDI). putnextctl(q, type) is provided as a multiprocessor-safe equivalent to the common call putctl(q->q_next, type), which is no longer allowed for DDI drivers.

Context

Base or Interrupt.

Synchronization constraints

Does not block.

Driver-defined basic locks, read/write locks, and sleep locks may not be held across calls to this function.

The caller cannot have the stream frozen [see freezestr(D3str)] when calling this function.

Examples

The send_ctl routine is used to pass control messages downstream. M_BREAK messages are handled with putnextctl (line 9). putnextctl1 (line 11) is used for M_DELAY messages, so that param can be used to specify the length of the delay. If an invalid message type is detected, send_ctl returns 0, indicating failure (line 13).
    1  int
    2  send_ctl(wrq, type, param)
    3	queue_t *wrq;
    4	uchar_t type;
    5	uchar_t param;
    6  {

7 switch (type) { 8 case M_BREAK: 9 return(putnextctl(wrq, M_BREAK));

10 case M_DELAY: 11 return(putnextctl1(wrq, M_DELAY, param));

12 default: 13 return(0); 14 } 15 }

Hardware applicability

All

Version applicability

ddi: 3, 5, 5mp, 6, 6mp, 7, 7mp, 7.1, 7.1mp, 8, 8mp

References

put(D2str), put(D3str), putctl(D3str), putctl1(D3str), putnextctl1(D3str)
19 June 2005
© 2005 The SCO Group, Inc. All rights reserved.
OpenServer 6 and UnixWare (SVR5) HDK - June 2005