![]() |
![]() |
![]() |
Send a message to a queue
#include <mqueue.h> int mq_send( mqd_t mqdes, const char * msg_ptr, size_t msg_len, unsigned int msg_prio );
libc
The mq_send() function puts a message of size msg_len and pointed to by msg_ptr into the queue indicated by mqdes. The new message has a priority of msg_prio.
The queue maintained is in priority order (priorities may range from 0 to MQ_PRIO_MAX), and in FIFO order within the same priority.
If the number of elements on the specified queue is equal to its mq_maxmsg, and neither O_NONBLOCK (in oflag of mq_open()) nor MQ_NONBLOCK (in the queue's mq_flags) has been set, the call to mq_send() blocks. It becomes unblocked when there's room on the queue to send the given message. If more than one mq_send() is blocked on a given queue, and space becomes available in that queue to send, then the mq_send() with the highest priority message is unblocked.
Calling write() with mqdes is analogous to calling mq_send() with a msg_prio of 0.
POSIX 1003.1 (Realtime Extensions)
Safety: | |
---|---|
Cancellation point | Yes |
Interrupt handler | No |
Signal handler | No |
Thread | Yes |
mq_close(), mq_open(), mq_receive()
![]() |
![]() |
![]() |