📄 vxwmsgq.html
字号:
<html><head><!-- /vobs/wpwr/docs/vxworks/ref/VXWMsgQ.html - generated by refgen from /vobs/wpwr/docs/vxworks/ref/VXWMsgQ.i --> <title> VXWMsgQ </title></head><body bgcolor="#FFFFFF"> <hr><a name="top"></a><p align=right><a href="libIndex.html"><i>VxWorks Reference Manual : Wind Foundation Classes</i></a></p></blockquote><h1>VXWMsgQ</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>VXWMsgQ</strong> - message queue classes</p></blockquote><h4>METHODS</h4><blockquote><p><p><b><i><a href="./VXWMsgQ.html#VXWMsgQ::VXWMsgQ">VXWMsgQ::VXWMsgQ</a></i>( )</b> - create and initialize a message queue<br><b><i><a href="./VXWMsgQ.html#VXWMsgQ::VXWMsgQ_1">VXWMsgQ::VXWMsgQ</a></i>( )</b> - build message-queue object from ID<br><b><i><a href="./VXWMsgQ.html#VXWMsgQ::~VXWMsgQ">VXWMsgQ::~VXWMsgQ</a></i>( )</b> - delete message queue<br><b><i><a href="./VXWMsgQ.html#VXWMsgQ::send">VXWMsgQ::send</a></i>( )</b> - send a message to message queue<br><b><i><a href="./VXWMsgQ.html#VXWMsgQ::receive">VXWMsgQ::receive</a></i>( )</b> - receive a message from message queue<br><b><i><a href="./VXWMsgQ.html#VXWMsgQ::numMsgs">VXWMsgQ::numMsgs</a></i>( )</b> - report the number of messages queued<br><b><i><a href="./VXWMsgQ.html#VXWMsgQ::info">VXWMsgQ::info</a></i>( )</b> - get information about message queue<br><b><i><a href="./VXWMsgQ.html#VXWMsgQ::show">VXWMsgQ::show</a></i>( )</b> - show information about a message queue<br><p></blockquote><h4>DESCRIPTION</h4><blockquote><p>The <b><a href="./VXWMsgQ.html#top">VXWMsgQ</a></b> class provides message queues, the primary intertaskcommunication mechanism within a single CPU. Message queues allowa variable number of messages (varying in length) to be queued infirst-in-first-out (FIFO) order. Any task or interrupt serviceroutine can send messages to a message queue. Any task can receivemessages from a message queue. Multiple tasks can send to andreceive from the same message queue. Full-duplex communicationbetween two tasks generally requires two message queues, one foreach direction.<p></blockquote><h4>CREATING AND USING MESSAGE QUEUES</h4><blockquote><p>The message-queue constructor takes parameters to specify themaximum number of messages that can be queued to that message queue andthe maximum length in bytes of each message. Enough buffer space ispre-allocated to accommodate the specified number of messages ofspecified length.<p>A task or interrupt service routine sends a message to a messagequeue with <b><i><a href="./VXWMsgQ.html#VXWMsgQ::send">VXWMsgQ::send</a></i>( )</b>. If no tasks are waiting for messageson the message queue, the message is simply added to the buffer ofmessages for that queue. If any tasks are already waiting toreceive a message from the message queue, the message isimmediately delivered to the first waiting task.<p>A task receives a message from a message queue with <b><i><a href="./VXWMsgQ.html#VXWMsgQ::receive">VXWMsgQ::receive</a></i>( )</b>.If any messages are already available in the message queue's buffer,the first message is immediately dequeued and returned to the caller.If no messages are available, the calling task blocks and joinsa queue of tasks waiting for messages. This queue of waiting tasks canbe ordered either by task priority or FIFO, as specified in an optionparameter when the queue is created.<p></blockquote><h4>TIMEOUTS</h4><blockquote><p>Both <b><i><a href="./VXWMsgQ.html#VXWMsgQ::send">VXWMsgQ::send</a></i>( )</b> and <b><i><a href="./VXWMsgQ.html#VXWMsgQ::receive">VXWMsgQ::receive</a></i>( )</b> take timeoutparameters. When sending a message, if no buffer space isavailable to queue the message, the timeout specifies how manyticks to wait for space to become available. When receiving amessage, the timeout specifies how many ticks to wait if no messageis immediately available. The <i>timeout</i> parameter can have thespecial values <b>NO_WAIT</b> (0) or <b>WAIT_FOREVER</b> (-1). <b>NO_WAIT</b> means theroutine should return immediately; <b>WAIT_FOREVER</b> means the routineshould never time out.<p></blockquote><h4>URGENT MESSAGES</h4><blockquote><p>The <b><i><a href="./VXWMsgQ.html#VXWMsgQ::send">VXWMsgQ::send</a></i>( )</b> routine allows the priority of a message to be specifiedas either normal (<b>MSG_PRI_NORMAL</b>) or urgent (<b>MSG_PRI_URGENT</b>). Normalpriority messages are added to the tail of the list of queued messages,while urgent priority messages are added to the head of the list.<p></blockquote><h4>INCLUDE FILES</h4><blockquote><p><b>vxwMsgQLib.h</b><p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./VXWMsgQ.html#top">VXWMsgQ</a></b>, <b><a href="./pipeDrv.html#top">pipeDrv</a></b>, <b><a href="./msgQSmLib.html#top">msgQSmLib</a></b>, <i>VxWorks Programmer's Guide: Basic OS</i><p><p><hr><a name="VXWMsgQ::VXWMsgQ"></a><p align=right><a href="rtnIndex.html"><i>Wind Foundation Classes : Methods</i></a></p></blockquote><h1><i>VXWMsgQ::VXWMsgQ</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>VXWMsgQ::VXWMsgQ</i>( )</strong> - create and initialize a message queue</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>VXWMsgQ ( int maxMsgs, int maxMsgLen, int opts )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This constructor creates a message queue capable of holding up to <i>maxMsgs</i>messages, each up to <i>maxMsgLen</i> bytes long. The queue can be created with the following options specified as <i>opts</i>:<dl><dt><b>MSG_Q_FIFO</b><dd>queue pended tasks in FIFO order.<p><dt><b>MSG_Q_PRIORITY</b><dd> queue pended tasks in priority order.<p></dl></blockquote><h4>RETURNS</h4><blockquote><p><p> N/A.<p></blockquote><h4>ERRNO</h4><blockquote><p><p>S_memLib_NOT_ENOUGH_MEMORY<br> - unable to allocate memory for message queue and message buffers.<p>S_intLib_NOT_ISR_CALLABLE<br> - called from an interrupt service routine.<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./VXWMsgQ.html#top">VXWMsgQ</a></b>, <b>vxwSmLib</b><hr><a name="VXWMsgQ::VXWMsgQ_1"></a><p align=right><a href="rtnIndex.html"><i>Wind Foundation Classes : Methods</i></a></p></blockquote><h1><i>VXWMsgQ::VXWMsgQ</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>VXWMsgQ::VXWMsgQ</i>( )</strong> - build message-queue object from ID</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>VXWMsgQ ( MSG_Q_ID id )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>Use this constructor to manipulate a message queue that was not createdusing C++ interfaces. The argument <i>id</i> is the message-queueidentifier returned and used by the C interface to the VxWorksmessage queue facility.<p></blockquote><h4>RETURNS</h4><blockquote><p>N/A.<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./VXWMsgQ.html#top">VXWMsgQ</a></b>, <b><a href="./msgQLib.html#top">msgQLib</a></b><hr><a name="VXWMsgQ::~VXWMsgQ"></a><p align=right><a href="rtnIndex.html"><i>Wind Foundation Classes : Methods</i></a></p></blockquote><h1><i>VXWMsgQ::~VXWMsgQ</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>VXWMsgQ::~VXWMsgQ</i>( )</strong> - delete message queue</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre> virtual ~VXWMsgQ ()</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This destructor deletes a message queue. Any task blocked on eithera <b><i><a href="./VXWMsgQ.html#VXWMsgQ::send">VXWMsgQ::send</a></i>( )</b> or <b><i><a href="./VXWMsgQ.html#VXWMsgQ::receive">VXWMsgQ::receive</a></i>( )</b> is unblocked and receives an errorfrom the call with <b>errno</b> set to S_objLib_OBJECT_DELETED. <p></blockquote><h4>RETURNS</h4><blockquote><p>N/A.<p></blockquote><h4>ERRNO</h4><blockquote><p><p>S_objLib_OBJ_ID_ERROR<br> - <i>msgQId</i> is invalid.<p>S_intLib_NOT_ISR_CALLABLE<br> - called from an interrupt service routine.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./VXWMsgQ.html#top">VXWMsgQ</a></b><hr><a name="VXWMsgQ::send"></a><p align=right><a href="rtnIndex.html"><i>Wind Foundation Classes : Methods</i></a></p></blockquote><h1><i>VXWMsgQ::send</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>VXWMsgQ::send</i>( )</strong> - send a message to message queue</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS send ( char * buffer, UINT nBytes, int timeout, int pri )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine sends the message in <i>buffer</i> of length <i>nBytes</i> toits message queue. If any tasks are already waiting to receivemessages on the queue, the message is immediately delivered to thefirst waiting task. If no task is waiting to receive messages, themessage is saved in the message queue.<p>The <i>timeout</i> parameter specifies the number of ticks to wait for freespace if the message queue is full. The <i>timeout</i> parameter can also have the following special values:<dl><dt><b>NO_WAIT</b><dd>return immediately, even if the message has not been sent. <p><dt><b>WAIT_FOREVER</b><dd> never time out. </dl><p>The <i>pri</i> parameter specifies the priority of the message being sent.The possible values are:<dl><dt><b>MSG_PRI_NORMAL</b><dd>normal priority; add the message to the tail of the list of queued messages.<p><dt><b>MSG_PRI_URGENT</b><dd> urgent priority; add the message to the head of the list of queued messages. </dl><p></blockquote><h4>USE BY INTERRUPT SERVICE ROUTINES</h4><blockquote><p>This routine can be called by interrupt service routines as well asby tasks. This is one of the primary means of communicationbetween an interrupt service routine and a task. When called from aninterrupt service routine, <i>timeout</i> must be <b>NO_WAIT</b>.<p></blockquote><h4>RETURNS</h4><blockquote><p>OK or ERROR.<p></blockquote><h4>ERRNO</h4><blockquote><p><p>S_objLib_OBJ_DELETED<br> - the message queue was deleted while waiting to a send message.<p>S_objLib_OBJ_UNAVAILABLE<br> - <i>timeout</i> is set to <b>NO_WAIT</b>, and the queue is full.<p>S_objLib_OBJ_TIMEOUT<br>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -