30.12.2013 Views

T-Kernel Specification (1.B0.02)

T-Kernel Specification (1.B0.02)

T-Kernel Specification (1.B0.02)

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

4.4. SYNCHRONIZATION AND COMMUNICATION FUNCTIONS 103<br />

tk rcv msg<br />

Receive Message from Mailbox<br />

[C Language Interface]<br />

ER ercd = tk_rcv_mbx ( ID mbxid, T_MSG **ppk_msg, TMO tmout ) ;<br />

[Parameters]<br />

ID mbxid Mailbox ID<br />

TMO tmout Timeout designation<br />

[Return Parameters]<br />

ER ercd Error code<br />

T MSG* pk msg Start address of message packet<br />

[Error Codes]<br />

E OK<br />

E ID<br />

E NOEXS<br />

E PAR<br />

E DLT<br />

E RLWAI<br />

E DISWAI<br />

E TMOUT<br />

E CTX<br />

Normal completion<br />

Invalid ID number (mbxid is invalid or cannot be used)<br />

Object does not exist (the mailbox designated in mbxid does not exist)<br />

Parameter error (tmout ≤ (−2))<br />

The object being waited for was deleted (the mailbox was deleted while waiting)<br />

Wait state released (tk rel wai received in wait state)<br />

Wait released by wait disabled state<br />

Polling failed or timeout<br />

Context error (issued from task-independent portion or in dispatch disabled state)<br />

[Description]<br />

Receives a message from the mailbox designated in mbxid. If no messages have been sent to the mailbox<br />

(the message queue is empty), the task issuing this system call enters WAIT state and is queued for<br />

message arrival. If there are messages in the mailbox, the task issuing this system call fetches the first<br />

message in the message queue, passing this in the return parameter pk msg.<br />

A maximum wait time (timeout) can be set in tmout. If the tmout time elapses before the wait release<br />

condition is met (no message arrives), the system call terminates, returning timeout error code E TMOUT.<br />

Only positive values can be set in tmout. The time base for tmout (time unit) is the same as that for<br />

system time (= 1 ms).<br />

When TMO POL = 0 is set in tmout, this means 0 was designated as the timeout value, and E TMOUT is<br />

returned without entering WAIT state even if no message arrives.<br />

When TMO FEVR = (−1) is set in tmout, this means infinity was designated as the timeout value, and<br />

the task continues to wait for message arrival without timing out.<br />

Copyright c○ 2002, 2003 by T-Engine Forum<br />

T-<strong>Kernel</strong> <strong>1.B0.02</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!