
CHAPTER 5 SYNCHRONOUS COMMUNICATION MANAGEMENT
User’s Manual U14833EJ2V0UM
61
5.5.3
Messages
All items of data (memory) exchanged between tasks via mailboxes are called “messages.” Using a mailbox, an
arbitrary task, handler, or processing routine can access the data, or messages, stored in the memory. In the
RX4000, however, the address of a message is only passed to the receiving side; the contents of the message are not
copied to any other area.
(1) Allocating message areas
Any memory area, such as a variable-length memory block, a fixed-length memory block, or a statically
secured area, can be used for messages. However, to transmit messages, an area is required for the kernel to
perform message management (message header), for which the top 4 bytes of the area is used (or the top 6
bytes in the case of messages with a specified priority). Accordingly, an area larger than 4 (or 6) bytes must be
secured for the message area.
The top address of the message area is passed to the mailbox when a message is transmitted. This address
must be a value that is an integral multiple of 4 (an integral multiple of 8 is recommended); otherwise operation
cannot be guaranteed.
For further details of the structure of the message header, refer to the
RX4000 (
μ
ITRON4.0) Technical User’s
Manual (U14835E)
.
(2) Contents of messages
The length and composition of messages to be transmitted to mailboxes are not prescribed in the RX4000;
rather they are determined by the tasks, handlers, and processing routines that communicate with each other
(i.e., by protocols).
(3) Message priority order
In the RX4000, if there are no tasks waiting for message reception when a message is transmitted, the
transmitted message is registered in the message queue of the mailbox. The order in which messages are
registered can be specified by the attribute of the mailbox, so for mailboxes with the attribute TA_MPRI,
messages are registered in order of priority. Values from 1 to 255 can be used to assign priority: the smaller
the value the higher the priority.
The priority of a message is stored in the 2 bytes following the 4th byte from the top of the message area.
Therefore when messages are communicated via a mailbox with the attribute TA_MPRI, the essence of the
message activates after the 6th byte from the top of the message area.
5.5.4
Transmitting messages
Messages are transmitted by issuing the service call snd_mbx.
If there is a message transmission request, the kernel checks the message reception waiting task queue of the
mailbox, and if there is a task waiting in this queue, it releases that task from the waiting state, at which point the task
receives the message. If there are no tasks waiting, messages are registered in the message queue of the mailbox in
the order specified by the attribute assigned when that mailbox was created (FIFO or priority order), and are saved for
the next message reception request.