Real-Time Embedded Multithreading: Using ThreadX and ARM

Chapter 12: Thread Communication with Message Queues

12.1 Introduction

Message queues are the primary means of inter-thread communication in ThreadX . One or more messages can reside in a message queue, which generally observes a FIFO discipline. A message queue that can hold just a single message is commonly called a mailbox.

The tx_queue_send service places messages in the rear of a queue and the tx_queue_ receive service removes messages from the front of a queue. The only exception to this protocol occurs when a thread is suspended while waiting for a message from an empty queue. In this case, ThreadX places the next message sent to the queue directly into the thread s destination area, thus bypassing the queue altogether. Figure 12.1 illustrates a message queue.


Figure 12.1: A message queue.

Each message queue is a public resource. ThreadX places no constraints on how message queues are used.

Applications can create message queues either during initialization or during run- time. There is no limit to the number of message queues an application may use.

Message queues can be created to support a variety of message sizes. The available message sizes are 1, 2, 4, 8, and 16 32-bit words. The message size is specified when the queue is created. If your application messages exceed 16 words, you must send your messages by pointer. To accomplish this, create a queue with a message size of one word (enough to hold a pointer), and then send and receive message pointers instead of the entire message.

The...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Embedded Systems Software
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.