1putctl(9F)               Kernel Functions for Drivers               putctl(9F)
2
3
4

NAME

6       putctl - send a control message to a queue
7

SYNOPSIS

9       #include <sys/stream.h>
10
11
12
13       int putctl(queue_t *q, int type);
14
15

INTERFACE LEVEL

17       Architecture independent level 1 (DDI/DKI).
18

PARAMETERS

20       q       Queue to which the message is to be sent.
21
22
23       type    Message type (must be control, not data type).
24
25

DESCRIPTION

27       The  putctl() function tests the type argument to make sure a data type
28       has not been specified, and then attempts to allocate a message  block.
29       putctl()  fails  if type is M_DATA, M_PROTO, or M_PCPROTO, or if a mes‐
30       sage block cannot be allocated.  If  successful,   putctl()  calls  the
31       put(9E)  routine  of the queue pointed to by q with the newly allocated
32       and initialized messages.
33

RETURN VALUES

35       On success, 1 is returned. If type is a data  type,  or  if  a  message
36       block cannot be allocated, 0 is returned.
37

CONTEXT

39       The  putctl()  function  can  be called from user, interrupt, or kernel
40       context.
41

EXAMPLES

43       Example 1 Using putctl()
44
45
46       The send_ctl() routine is used to  pass  control  messages  downstream.
47       M_BREAK messages are handled with putctl() (line 11). putctl1(9F) (line
48       16) is used for M_DELAY messages, so that parm can be used  to  specify
49       the  length  of the delay. In either case, if a message block cannot be
50       allocated a variable recording the number  of  allocation  failures  is
51       incremented  (lines  12,  17).  If an invalid message type is detected,
52       cmn_err(9F) panics the system (line 21).
53
54
55         1  void
56          2  send_ctl(wrq, type, parm)
57          3      queue_t *wrq;
58          4      uchar_t type;
59          5      uchar_t parm;
60          6  {
61          7         extern int num_alloc_fail;
62          8
63          9       switch (type) {
64         10         case M_BREAK:
65         11             if (!putctl(wrq->q_next, M_BREAK))
66         12                      num_alloc_fail++;
67         13               break;
68         14
69         15       case M_DELAY:
70         16             if (!putctl1(wrq->q_next, M_DELAY, parm))
71         17                      num_alloc_fail++;
72         18             break;
73         19
74         20       default:
75         21             cmn_err(CE_PANIC, "send_ctl: bad message type passed");
76         22               break;
77         23         }
78         24  }
79
80

SEE ALSO

82       put(9E), cmn_err(9F), datamsg(9F), putctl1(9F), putnextctl(9F)
83
84
85       Writing Device Drivers
86
87
88       STREAMS Programming Guide
89
90
91
92SunOS 5.11                        16 Jan 2006                       putctl(9F)
Impressum