mq_send, mq_timedsend, mq_reltimedsend_np - send a message to a message queue
#include <mqueue.h> int mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio);
#include <mqueue.h> #include <time.h> int mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio, const struct timespec *restrict abs_timeout);
int mq_reltimedsend_np(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio, const struct timespec *restrict rel_timeout);
The mq_send() function adds the message pointed to by the argument msg_ptr to the message queue specified by mqdes. The msg_len argument specifies the length of the message in bytes pointed to by msg_ptr. The value of msg_len is less than or equal to the mq_msgsize attribute of the message queue, or mq_send() fails.
If the specified message queue is not full, mq_send() behaves as if the message is inserted into the message queue at the position indicated by the msg_prio argument. A message with a larger numeric value of msg_prio is inserted before messages with lower values of msg_prio. A message will be inserted after other messages in the queue, if any, with equal msg_prio. The value of msg_prio must be greater than zero and less than or equal to MQ_PRIO_MAX.
If the specified message queue is full and O_NONBLOCK is not set in the message queue description associated with mqdes (see mq_open(3C) and mq_setattr(3C)), mq_send() blocks until space becomes available to enqueue the message, or until mq_send() is interrupted by a signal. If more than one thread is waiting to send when space becomes available in the message queue, then the thread of the highest priority which has been waiting the longest is unblocked to send its message. Otherwise, it is unspecified which waiting thread is unblocked. If the specified message queue is full and O_NONBLOCK is set in the message queue description associated with mqdes, the message is not queued and mq_send() returns an error.
The mq_timedsend() function adds a message to the message queue specified by mqdes in the manner defined for the mq_send() function. However, if the specified message queue is full and O_NONBLOCK is not set in the message queue description associated with mqdes, the wait for sufficient room in the queue is terminated when the specified timeout expires. If O_NONBLOCK is set in the message queue description, this function is equivalent to mq_send().
The mq_reltimedsend_np() function is identical to the mq_timedsend() function, except that the timeout is specified as a relative time interval.
For mq_timedsend(), the timeout expires when the absolute time specified by abs_timeout passes, as measured by the CLOCK_REALTIME clock (that is, when the value of that clock equals or exceeds abs_timeout), or if the absolute time specified by abs_timeout has already been passed at the time of the call.
For mq_reltimedsend_np(), the timeout expires when the time interval specified by rel_timeout passes, as measured by the CLOCK_REALTIME clock, or if the time interval specified by rel_timeout is negative at the time of the call.
The resolution of the timeout is the resolution of the CLOCK_REALTIME clock. The timespec argument is defined in the <time.h> header.
Under no circumstance does the operation fail with a timeout if there is sufficient room in the queue to add the message immediately. The validity of the timeout parameter need not be checked when there is sufficient room in the queue.
Upon successful completion, mq_send(), mq_timedsend(), and mq_reltimedsend_np() return 0. Otherwise, no message is enqueued, the functions return -1, and errno is set to indicate the error.
The mq_send(), mq_timedsend(), and mq_reltimedsend_np() functions will fail if:
EAGAIN
EBADF
EINTR
EINVAL
EINVAL
EMSGSIZE
ETIMEDOUT
See attributes(5) for descriptions of the following attributes:
|
For mq_send() and mq_timedsend(), see standards(5).
sysconf(3C), mqueue.h(3HEAD), mq_open(3C), mq_receive(3C), mq_setattr(3C), attributes(5), standards(5)
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |