<p>We have a vxWorks design which requires one task to process both high and low priority messages sent over two message queues.<br>
The messages for a given priority have to be processed in FIFO order.  </p>

<p>For example, process all the high priority messages in the order they were received, then process the low priority messages.  If there is no high priority message, then process the low priority message immediately.</p>

<p>Is there a way to do this?</p>

In vxWorks, you can't wait directly on multiple queues.  You can however use the OS events (from eventLib) to achieve this result.
Here is a simple code snippet:
```
```
MSG_Q_ID lowQ, hiQ;

void Init() {
// Task Initialization Code.  This should be called from the task that will
// be receiving the messages
...
hiQ = msgQCreate(...);
lowQ = msgQCreate(...);
msgQEvStart(hiQ, VX_EV01);  // Event 1 sent when hiQ receives message
msgQEvStart(loQ, VX_EV02);  // Event 2 sent when loQ receives message
...
}
void RxMessages() {
...
  UINT32 ev;   // Event received

   // Blocks until we receive Event 1 or 2
   eventReceive(VX_EV01 | VX_EV02, EVENT_WAIT_ANY, WAIT_FOREVER, &ev);
   if(ev & VX_EV01) {
      msgQReceive(hiQ, ...);
   }
   if(ev & VX_EV02) {
      msgQReceive(loQ, ...);
   }
}
```
```
Note that you need to modify that code to make sure you drain all your queues in case there is more than one message that was received.
The same mechanism can also be applied to Binary semaphores using the semEvStart() function.