This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs. |
Send a message to a message queue
#include <mqueue.h> #include <time.h> int mq_timedsend( mqd_t mqdes, const char * msg_ptr, size_t msg_len, unsigned int msg_prio, const struct timespec * abs_timeout );
Use the -l c option to qcc to link against this library. This library is usually included automatically.
Use the -l mq option to qcc to link against this library.
The mq_timedsend() 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.
Neutrino supports two implementations of message queues: a traditional implementation, and an alternate one that uses asynchronous messages. For more information, see the entry for mq and mqueue in the Utilities Reference. |
The queue maintained is in priority order, and in FIFO order within the same priority.
If the number of elements on the specified queue is equal to its mq_maxmsg, and O_NONBLOCK (in oflag of mq_open()) hasn't been set, the call to mq_timedsend() blocks. It becomes unblocked when there's room on the queue to send the given message. If more than one mq_timedsend() is blocked on a given queue, and space becomes available in that queue to send, then the mq_timedsend() with the highest priority message is unblocked.
In the traditional (mqueue) implementation, calling write() with mqdes is analogous to calling mq_timedsend() with a msg_prio of 0.
-1 if an error occurred (errno is set). Any other value indicates success.
See the example for mq_timedreceive().
Safety: | |
---|---|
Cancellation point | Yes |
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |
mq_close(), mq_open(), mq_receive(), mq_send(), mq_timedreceive(), timespec
mq, mqueue in the Utilities Reference