
CHAPTER 5 SYNCHRONOUS COMMUNICATION MANAGEMENT
User’s Manual U14833EJ2V0UM
62
5.5.5
Receiving messages
Messages are received by issuing one of the service calls rcv_mbx, trcv_mbx, or (i)prcv_mbx.
If there is a message reception request, the kernel checks the message queue of the mailbox. If there are
unreceived messages registered in the queue, the message at the top of the queue is released and passed to the task
with that address. If there are no messages registered in the queue, when the service calls rcv_mbx and trcv_mbx
are issued, the task is put into a mail reception waiting state: until mail is received in the case of the former, and until
either mail is received or a specified time has elapsed in the case of the latter. The issuance of (i)prcv_mbx results in
message reception failure, and the error code E_TMOUT is returned, indicating that polling failed.
Tasks waiting to receive messages are registered in the waiting task queue of the mailbox. Because multiple tasks
can be waiting in the waiting task queue of the same mailbox, a request for message reception sent to a mailbox in
whose waiting task queue tasks are already waiting will not result in an error; the task will simply be put in the
message reception waiting state.
Tasks can be registered in the waiting task queue of the mailbox in two ways. In the case of mailboxes with an
attribute of TA_TPRI, tasks are registered in the queue in order of their respective priorities, and in the case of
mailboxes with an attribute of TA_TFIFO, tasks are registered in the order in which message reception requests were
sent. Tasks are released from waiting in order activation from the top of the queue.
5.5.6
Obtaining mailbox information
Mailbox information such as the presence or absence of a waiting task can be obtained by using the service calls
ref_mbx and iref_mbx. For details of each service call, refer to
CHAPTER 13
.
5.5.7
Examples of message communication using mailboxes
Some examples of communication using mailboxes are shown below.
(1) cre_mbx is issued creating a mailbox.
(2) Task A issues rcv_mbx to receive a message and a message reception request is sent to mailbox X. However,
because no messages have been sent to mailbox X, task A is put in the message reception waiting state.
Task A
Reception request
Message reception impossible
Task A
Running state
Waiting state
Mailbox X
Registration
Mailbox X
rcv_mbx