RTEMS Logo

RTEMS 4.6.1 On-Line Library


Message Passing Manager mq_send - Send a Message to a Message Queue

PREV UP NEXT Bookshelf RTEMS POSIX API User's Guide

16.4.4: mq_send - Send a Message to a Message Queue

CALLING SEQUENCE:

#include<mqueue.h>
int mq_send(
  mqd_t        mqdes,
  const char  *msg_ptr,
  size_t       msg_len,
  unsigned int msg_prio
);

STATUS CODES:

EBADF - The descriptor does not represent a valid message queue, or the queue was opened for read only O_RDONLY EINVAL - The value of msg_prio was greater than the MQ_PRIO_MAX. EMSGSIZE - The msg_len is greater than the mq_msgsize attribute of the message queue EAGAIN - The message queue is non-blocking, and there is no room on the queue for another message as specified by the mq_maxmsg. EINTR - The message queue is blocking. While the process was waiting for free space on the queue, a signal arrived that interrupted the wait.

DESCRIPTION:

The mq_send() function adds the message pointed to by the argument msg_ptr to the message queue specified by mqdes. Each message is assigned a priority , from 0 to MQ_PRIO_MAX. MQ_PRIO_MAX is defined in <limits.h> and must be at least 32. Messages are added to the queue in order of their priority. The highest priority message is at the front of the queue.

The maximum number of messages that a message queue may accept is specified at creation by the mq_maxmsg field of the attribute structure. If this amount is exceeded, the behavior of the process is determined according to what oflag was used when the message queue was opened. If the queue was opened with O_NONBLOCK flag set, then the EAGAIN error is returned. If the O_NONBLOCK flag was not set, the process blocks and waits for space on the queue, unless it is interrupted by a signal.

Upon successful completion, the mq_send () function returns a value of zero. Otherwise, no message is enqueued, the function returns -1, and errno is set to indicate the error.

NOTES:

If the specified message queue is not full, mq_send inserts the message at the position indicated by the msg_prio argument.


PREV UP NEXT Bookshelf RTEMS POSIX API User's Guide

Copyright © 1988-2004 OAR Corporation