Message Queues
6-16
Conceptually, the reader thread owns a message queue. The reader thread
opens a message queue. Writer threads locate existing message queues to
get access to them.
Messages must be allocated from the MSGQ module. Once a message is
allocated, it can be sent on any message queue. Once a message is sent, the
writer loses ownership of the message and should not attempt to modify the
message. Once the reader receives the message, it owns the message. It
may either free the message or re-use the message.
Messages in a message queue can be of variable length. The only
requirement is that the first field in the definition of a message must be a
MSGQ_MsgHeader element.
typedef struct MyMsg {
MSGQ_MsgHeader header;
...
} MyMsg;
The MSGQ API uses the MSGQ_MsgHeader internally. Your application
should not modify or directly access the fields in the MSGQ_MsgHeader.
The MSGQ module has the following components:
❏ MSGQ API. Applications call the MSGQ functions to open and use a
message queue object to send and receive messages. For an overview,
see “MSGQ APIs” on page 17. For details, see the sections on the
individual APIs.
❏ Allocators. Messages sent via MSGQ must be allocated by an allocator.
The allocator determines where and how the memory for the message is
allocated. For more about allocators, see “Allocators” on page 20.
❏ Transports. Transports are responsible for locating and sending
messages with other processors. For more about transports, see
“Transports” on page 21.
Figure 6-4. Components of the MSGQ Architecture
MSGQ APIs
Allocators
Drivers
Transports