VxWorks Starter Notes-Message Queuing
one. Concept:
1. Message Queuing is used to pass information between tasks.
2. Multiple tasks send or receive messages to the same message queue.
3.ISR can send messages in no_wait mode.
Two. Control function: 1. msgqcreate msg_q_id msgqcreate (int maxmsgs,/* Message Queue Length (maximum number of messages)/int maxmsglength,/* Maximum length of message in message queue */INT Options/* Fifo/priori TY waits for Task queue mode */)
2. Msgqsend
STATUS msgqsend (msg_q_id msgqid,/* Message queue ID/char *buffer,/* Pointer to the message to be sent/UINT nbytes,/* Message length */int timeout,/* Timeout (tick)/no-wait/forever */INT priority/* Msg_pri_normal or Msg_pri_urgent * *)
3.msgQReceive
int msgqreceive (msg_q_id msgqid,/* Message queue ID/char *buffer,/* Pointer to the receiving buffer of the message/UINT maxnbytes,/* Receive buffered bytes/int time Out/* Timeout time (tick)/no-wait/forever * *)
4. Msgqdelete
STATUS msgqdelete (msg_q_id msgqid/* ID of message queue to be deleted/*)
Once the Msgqdelete () operation completes, the task that is blocked on the message queue, including the task that is blocked on the send queue, the receive queue, is awakened (Unpend), and the ID of the message queue is no longer valid.
three. Recommendations:
1. Create a dedicated msgq for each task.
2. All message that needs to be sent to the task is sent to the only msgq.
3. Because Message Queuing has the Copy & MaxLength feature, we can only store pointers in Message Queuing.