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.

54 CHAPTER 4. T-KERNEL/OS FUNCTIONS<br />

tk slp tsk<br />

Sleep Task<br />

[C Language Interface]<br />

ER ercd = tk_slp_tsk ( TMO tmout ) ;<br />

[Parameters]<br />

TMO tmout Timeout designation<br />

[Return Parameters]<br />

ER ercd Error code<br />

[Error Codes]<br />

E OK<br />

E PAR<br />

E RLWAI<br />

E DISWAI<br />

E TMOUT<br />

E CTX<br />

Normal completion<br />

Parameter error (tmout ≤ (−2))<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 />

Changes the state of the invoking task from RUN state to sleep state (WAIT for tk wup tsk).<br />

If tk wup tsk is issued for the invoking task before the time designated in tmout has elapsed, this system<br />

call completes normally. If timeout occurs before tk wup tsk is issued, error code E TMOUT is returned.<br />

Designating tmout = TMO FEVR = (−1) means endless wait. In this case, the task stays in waiting state<br />

until tk wup tsk is issued.<br />

[Additional Notes]<br />

Since tk slp tsk is a system call that puts the invoking task into a wait state, tk slp tsk can never<br />

be nested. It is possible, however, for another task to issue tk sus tsk for a task that was put in a wait<br />

state by tk slp tsk. In this case the task goes to WAIT-SUSPEND state.<br />

For simply delaying a task, tk dly tsk should be used rather than tk slp tsk.<br />

The task sleep function is intended for use by applications and as a rule should not be used by middleware.<br />

The reason is that attempting to achieve synchronization by putting a task to sleep in two or more<br />

places would cause confusion, leading to misoperation. For example, if sleep were used by both an<br />

application and middleware for synchronization, a wakeup request might arise in the application while<br />

middleware has the task sleeping. In such a situation, normal operation would not be possible in either<br />

the application or middleware. Proper task synchronization is not possible because it is not clear where<br />

the wait for wakeup originated. Task sleep is often used as a simple means of task synchronization.<br />

Applications should be able to use it freely, which means as a rule it should not be used by middleware.<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!