1 .\" Copyright (c) 2005 David Xu <davidxu@FreeBSD.org>
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice(s), this list of conditions and the following disclaimer as
9 .\" the first lines of this file unmodified other than the possible
10 .\" addition of one or more copyright notices.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice(s), this list of conditions and the following disclaimer in
13 .\" the documentation and/or other materials provided with the
16 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
17 .\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
20 .\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 .\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 .\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 .\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26 .\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 .\" Portions of this text are reprinted and reproduced in electronic form
29 .\" from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology --
30 .\" Portable Operating System Interface (POSIX), The Open Group Base
31 .\" Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of
32 .\" Electrical and Electronics Engineers, Inc and The Open Group. In the
33 .\" event of any discrepancy between this version and the original IEEE and
34 .\" The Open Group Standard, the original IEEE and The Open Group Standard is
35 .\" the referee document. The original Standard can be obtained online at
36 .\" http://www.opengroup.org/unix/online.html.
42 .Nm mq_receive , mq_timedreceive
43 .Nd "receive a message from message queue (REALTIME)"
53 .Fa "unsigned *msg_prio"
60 .Fa "unsigned *msg_prio"
61 .Fa "const struct timespec *abs_timeout"
66 system call receives oldest of the highest priority message(s) from the
67 message queue specified by
69 If the size of the buffer in bytes, specified by the
71 argument, is less than the
73 attribute of the message queue, the system call will fail and return an
75 Otherwise, the selected message will be removed from the queue
76 and copied to the buffer pointed to by the
84 the priority of the selected message will be stored in the
85 location referenced by
87 If the specified message queue is empty and
89 is not set in the message queue description associated with
92 will block until a message is enqueued on the message queue or until
94 is interrupted by a signal.
95 If more than one thread is waiting to receive
96 a message when a message arrives at an empty queue and the Priority
97 Scheduling option is supported, then the thread of highest priority that
98 has been waiting the longest will be selected to receive the message.
99 Otherwise, it is unspecified which waiting thread receives the message.
100 If the specified message queue is empty and
102 is set in the message queue description associated with
105 will be removed from the queue, and
107 will return an error.
111 system call will receive the oldest of the highest priority messages from the
112 message queue specified by
119 was not specified when the message queue was opened via the
121 system call, and no message exists on the queue to satisfy the receive, the wait
122 for such a message will be terminated when the specified timeout expires.
125 is set, this system call is equivalent to
128 The timeout expires when the absolute time specified by
130 passes, as measured by the clock on which timeouts are based (that is, when
131 the value of that clock equals or exceeds
133 or if the absolute time specified by
135 has already been passed at the time of the call.
137 The timeout is based on the
141 Upon successful completion, the
145 system calls return the length of the selected message in bytes and the
146 message is removed from the queue.
147 Otherwise, no message is removed
148 from the queue, the system call returns a value of \-1,
149 and the global variable
151 is set to indicate the error.
162 flag is set in the message queue description associated with
164 and the specified message queue is empty.
168 argument is not a valid message queue descriptor open for reading.
170 The specified message buffer size,
172 is less than the message size attribute of the message queue.
178 operation was interrupted by a signal.
180 The process or thread would have blocked, and the
182 parameter specified a nanoseconds field value less than zero or greater
183 than or equal to 1000 million.
187 flag was not set when the message queue was opened, but no message arrived
188 on the queue before the specified timeout expired.
199 system calls conform to
204 message queues first appeared in
207 Portions of this text are reprinted and reproduced in electronic form
208 from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology --
209 Portable Operating System Interface (POSIX), The Open Group Base
210 Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of
211 Electrical and Electronics Engineers, Inc and The Open Group. In the
212 event of any discrepancy between this version and the original IEEE and
213 The Open Group Standard, the original IEEE and The Open Group Standard is
214 the referee document. The original Standard can be obtained online at
215 http://www.opengroup.org/unix/online.html.