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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

4.4. SYNCHRONIZATION AND COMMUNICATION FUNCTIONS 83<br />

tk wai sem<br />

Wait on Semaphore<br />

[C Language Interface]<br />

ER ercd = tk_wai_sem ( ID semid, INT cnt, TMO tmout ) ;<br />

[Parameters]<br />

ID semid Semaphore ID<br />

INT cnt Resource request count<br />

TMO tmout Timeout designation<br />

[Return Parameters]<br />

ER ercd Error code<br />

[Error Codes]<br />

E OK Normal completion<br />

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

E NOEXS Object does not exist (the semaphore designated in semid does not exist)<br />

E PAR Parameter error (tmout ≤ (−2), cnt ≤ 0)<br />

E DLT The object being waited for was deleted (the designated semaphore was deleted while<br />

waiting)<br />

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

E DISWAI Wait released by wait disabled state<br />

E TMOUT Polling failed or timeout<br />

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

[Description]<br />

Gets from the semaphore designated in semid the number of resources indicated in cnt. If the requested<br />

resources can be allocated, the task issuing this system call does not enter WAIT state but continues<br />

executing. In this case the semaphore count (semcnt) is decreased by the size of cnt. If the resources<br />

are not available, the task issuing this system call enters WAIT state, and is put in the queue of tasks<br />

waiting for the semaphore. The semaphore count (semcnt) for this semaphore does not change in this<br />

case.<br />

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

condition is met (tk sig sem is not executed), the system call terminates, returning timeout error code<br />

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 resources are acquired.<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!