⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mqpxlib.html

📁 Vxworks API操作系统和驱动程序设计API。压缩的HTML文件
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<html><head><!-- /vobs/wpwr/docs/vxworks/ref/mqPxLib.html - generated by refgen from mqPxLib.c --> <title> mqPxLib </title></head><body bgcolor="#FFFFFF"> <hr><a name="top"></a><p align=right><a href="libIndex.htm"><i>VxWorks API Reference :  OS Libraries</i></a></p></blockquote><h1>mqPxLib</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong>mqPxLib</strong> - message queue library (POSIX) </p></blockquote><h4>ROUTINES</h4><blockquote><p><p><b><a href="./mqPxLib.html#mqPxLibInit">mqPxLibInit</a>(&nbsp;)</b>  -  initialize the POSIX message queue library<br><b><a href="./mqPxLib.html#mq_open">mq_open</a>(&nbsp;)</b>  -  open a message queue (POSIX)<br><b><a href="./mqPxLib.html#mq_receive">mq_receive</a>(&nbsp;)</b>  -  receive a message from a message queue (POSIX)<br><b><a href="./mqPxLib.html#mq_send">mq_send</a>(&nbsp;)</b>  -  send a message to a message queue (POSIX)<br><b><a href="./mqPxLib.html#mq_close">mq_close</a>(&nbsp;)</b>  -  close a message queue (POSIX)<br><b><a href="./mqPxLib.html#mq_unlink">mq_unlink</a>(&nbsp;)</b>  -  remove a message queue (POSIX)<br><b><a href="./mqPxLib.html#mq_notify">mq_notify</a>(&nbsp;)</b>  -  notify a task that a message is available on a queue (POSIX)<br><b><a href="./mqPxLib.html#mq_setattr">mq_setattr</a>(&nbsp;)</b>  -  set message queue attributes (POSIX)<br><b><a href="./mqPxLib.html#mq_getattr">mq_getattr</a>(&nbsp;)</b>  -  get message queue attributes (POSIX)<br><p></blockquote><h4>DESCRIPTION</h4><blockquote><p>This library implements the message-queue interface defined in thePOSIX 1003.1b standard, as an alternative to the VxWorks-specificmessage queue design in <b><a href="./msgQLib.html#top">msgQLib</a></b>.  These message queues are accessedthrough names; each message queue supports multiple sending and receiving tasks.<p>The message queue interface imposes a fixed upper bound on the size ofmessages that can be sent to a specific message queue.  The size is set onan individual queue basis.  The value may not be changed dynamically.<p>This interface allows a task be notified asynchronously of theavailability of a message on the queue.  The purpose of this feature is tolet the task to perform other functions and yet still be notified that amessage has become available on the queue.<p></blockquote><h4>MESSAGE QUEUE DESCRIPTOR DELETION</h4><blockquote><p>The <b><a href="./mqPxLib.html#mq_close">mq_close</a>(&nbsp;)</b> call terminates a message queue descriptor anddeallocates any associated memory.  When deleting message queuedescriptors, take care to avoid interfering with other tasks that areusing the same descriptor.  Tasks should only close messagequeue descriptors that the same task has opened successfully.<p>The routines in this library conform to POSIX 1003.1b.<p></blockquote><h4>INCLUDE FILES</h4><blockquote><p><b>mqueue.h</b><p></blockquote><h4>SEE ALSO</h4><blockquote><p>POSIX 1003.1b document, <b><a href="./msgQLib.html#top">msgQLib</a></b>,<i>VxWorks Programmer's Guide: Basic OS </i><hr><a name="mqPxLibInit"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries :  Routines</i></a></p></blockquote><h1>mqPxLibInit(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong>mqPxLibInit(&nbsp;)</strong> - initialize the POSIX message queue library</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>int mqPxLibInit    (    int hashSize              /* log2 of number of hash buckets */    )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine initializes the POSIX message queue facility.  If <i>hashSize</i> is0, the default value is taken from <b>MQ_HASH_SIZE_DEFAULT</b>.<p></blockquote><h4>RETURNS</h4><blockquote><p>OK or ERROR.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./mqPxLib.html#top">mqPxLib</a></b><hr><a name="mq_open"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries :  Routines</i></a></p></blockquote><h1>mq_open(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong>mq_open(&nbsp;)</strong> - open a message queue (POSIX)</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>mqd_t mq_open    (    const char * mqName,      /* name of queue to open */    int          oflags,      /* open flags */                 ...          /* extra optional parameters */    )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine establishes a connection between a named message queue and thecalling task.  After a call to <b><a href="./mqPxLib.html#mq_open">mq_open</a>(&nbsp;)</b>, the task can reference themessage queue using the address returned by the call.  The message queueremains usable until the queue is closed by a successful call to <b><a href="./mqPxLib.html#mq_close">mq_close</a>(&nbsp;)</b>.<p>The <i>oflags</i> argument controls whether the message queue is created or merelyaccessed by the <b><a href="./mqPxLib.html#mq_open">mq_open</a>(&nbsp;)</b> call.  The following flag bits can be setin <i>oflags</i>:<dl><dt><b>O_RDONLY</b><dd>Open the message queue for receiving messages.  The task can use the returned message queue descriptor with <b><a href="./mqPxLib.html#mq_receive">mq_receive</a>(&nbsp;)</b>, but not <b><a href="./mqPxLib.html#mq_send">mq_send</a>(&nbsp;)</b>.<dt><b>O_WRONLY</b><dd>Open the message queue for sending messages.  The task can use thereturned message queue descriptor with <b><a href="./mqPxLib.html#mq_send">mq_send</a>(&nbsp;)</b>, but not <b><a href="./mqPxLib.html#mq_receive">mq_receive</a>(&nbsp;)</b>.<dt><b>O_RDWR</b><dd>Open the queue for both receiving and sending messages.  The task can useany of the functions allowed for <b>O_RDONLY</b> and <b>O_WRONLY</b>.</dl><p>Any combination of the remaining flags can be specified in <i>oflags</i>:<dl><dt><b>O_CREAT</b><dd>This flag is used to create a message queue if it does not already exist.If <b>O_CREAT</b> is set and the message queue already exists, then <b>O_CREAT</b> hasno effect except as noted below under <b>O_EXCL</b>.  Otherwise, <b><a href="./mqPxLib.html#mq_open">mq_open</a>(&nbsp;)</b>creates a message queue.  The <b>O_CREAT</b> flag requires a third and fourthargument: <i>mode</i>, which is of type <b>mode_t</b>, and <i>pAttr</i>, which is of typepointer to an <b>mq_attr</b> structure.  The value of <i>mode</i> has no effect inthis implementation.  If <i>pAttr</i> is NULL, the message queue is createdwith implementation-defined default message queue attributes.  If <i>pAttr</i>is non-NULL, the message queue attributes <b>mq_maxmsg</b> and <b>mq_msgsize</b> areset to the values of the corresponding members in the <b>mq_attr</b> structurereferred to by <i>pAttr</i>; if either attribute is less than or equal to zero,an error is returned and errno is set to EINVAL.<dt><b>O_EXCL</b><dd>This flag is used to test whether a message queue already exists.If <b>O_EXCL</b> and <b>O_CREAT</b> are set, <b><a href="./mqPxLib.html#mq_open">mq_open</a>(&nbsp;)</b> fails if the message queue nameexists.<dt><b>O_NONBLOCK</b><dd>The setting of this flag is associated with the open message queue descriptorand determines whether a <b><a href="./mqPxLib.html#mq_send">mq_send</a>(&nbsp;)</b> or <b><a href="./mqPxLib.html#mq_receive">mq_receive</a>(&nbsp;)</b> will wait for resourcesor messages that are not currently available, or fail with errno set to EAGAIN.  </dl><p>The <b><a href="./mqPxLib.html#mq_open">mq_open</a>(&nbsp;)</b> call does not add or remove messages from the queue.<p></blockquote><h4>NOTE</h4><blockquote><p><p>Some POSIX functionality is not yet supported:<p>&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;A&nbsp;message&nbsp;queue&nbsp;cannot&nbsp;be&nbsp;closed&nbsp;with&nbsp;calls&nbsp;to&nbsp;<b>_exit(&nbsp;)</b>&nbsp;or&nbsp;<b>exec(&nbsp;)</b>.<br>&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;A&nbsp;message&nbsp;queue&nbsp;cannot&nbsp;be&nbsp;implemented&nbsp;as&nbsp;a&nbsp;file.<br>&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;Message&nbsp;queue&nbsp;names&nbsp;will&nbsp;not&nbsp;appear&nbsp;in&nbsp;the&nbsp;file&nbsp;system.<p></blockquote><h4>RETURNS</h4><blockquote><p>A message queue descriptor, otherwise -1 (ERROR).<p></blockquote><h4>ERRNO</h4><blockquote><p>EEXIST, EINVAL, ENOENT, ENOSPC<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./mqPxLib.html#top">mqPxLib</a></b>, <b><a href="./mqPxLib.html#mq_send">mq_send</a>(&nbsp;)</b>, <b><a href="./mqPxLib.html#mq_receive">mq_receive</a>(&nbsp;)</b>, <b><a href="./mqPxLib.html#mq_close">mq_close</a>(&nbsp;)</b>, <b><a href="./mqPxLib.html#mq_setattr">mq_setattr</a>(&nbsp;)</b>, <b><a href="./mqPxLib.html#mq_getattr">mq_getattr</a>(&nbsp;)</b>,  <b><a href="./mqPxLib.html#mq_unlink">mq_unlink</a>(&nbsp;)</b><hr><a name="mq_receive"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries :  Routines</i></a></p></blockquote><h1>mq_receive(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong>mq_receive(&nbsp;)</strong> - receive a message from a message queue (POSIX)</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>ssize_t mq_receive    (    mqd_t  mqdes,             /* message queue descriptor */    void * pMsg,              /* buffer to receive message */    size_t msgLen,            /* size of buffer, in bytes */    int *  pMsgPrio           /* if not NULL, priority of message */    )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine receives the oldest of the highest priority message fromthe message queue specified by <i>mqdes</i>.  If the size of the buffer inbytes, specified by the <i>msgLen</i> argument, is less than the <b>mq_msgsize</b>attribute of the message queue, <b><a href="./mqPxLib.html#mq_receive">mq_receive</a>(&nbsp;)</b> will fail and return anerror.  Otherwise, the selected message is removed from the queue andcopied to <i>pMsg</i>.<p>If <i>pMsgPrio</i> is not NULL, the priority of the selected messagewill be stored in <i>pMsgPrio</i>.<p>If the message queue is empty and <b>O_NONBLOCK</b> is not set in the messagequeue's description, <b><a href="./mqPxLib.html#mq_receive">mq_receive</a>(&nbsp;)</b> will block until a message is added tothe message queue, or until it is interrupted by a signal.  If more thanone task is waiting to receive a message when a message arrives at anempty queue, the task of highest priority that has been waiting thelongest will be selected to receive the message.  If the specified messagequeue is empty and <b>O_NONBLOCK</b> is set in the message queue's description,no message is removed from the queue, and <b><a href="./mqPxLib.html#mq_receive">mq_receive</a>(&nbsp;)</b> returns an error.<p></blockquote><h4>RETURNS</h4><blockquote><p>The length of the selected message in bytes, otherwise -1 (ERROR). <p></blockquote><h4>ERRNO</h4><blockquote><p>EAGAIN, EBADF, EMSGSIZE, EINTR<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./mqPxLib.html#top">mqPxLib</a></b>, <b><a href="./mqPxLib.html#mq_send">mq_send</a>(&nbsp;)</b><hr><a name="mq_send"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries :  Routines</i></a></p></blockquote><h1>mq_send(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong>mq_send(&nbsp;)</strong> - send a message to a message queue (POSIX)</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>int mq_send    (    mqd_t        mqdes,       /* message queue descriptor */    const void * pMsg,        /* message to send */    size_t       msgLen,      /* size of message, in bytes */    int          msgPrio      /* priority of message */    )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine adds the message <i>pMsg</i> to the message queue<i>mqdes</i>.  The <i>msgLen</i> parameter specifies the length of the message inbytes pointed to by <i>pMsg</i>.  The value of <i>pMsg</i> must be less than orequal to the <b>mq_msgsize</b> attribute of the message queue, or <b><a href="./mqPxLib.html#mq_send">mq_send</a>(&nbsp;)</b>will fail.<p>If the message queue is not full, <b><a href="./mqPxLib.html#mq_send">mq_send</a>(&nbsp;)</b> will behave as if the message

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -