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.9. SYSTEM MANAGEMENT FUNCTIONS 191<br />

tk rot rdq<br />

Rotate Ready Queue<br />

[C Language Interface]<br />

ER ercd = tk_rot_rdq ( PRI tskpri ) ;<br />

[Parameters]<br />

PRI tskpri Task priority<br />

[Return Parameters]<br />

ER ercd Error code<br />

[Error Codes]<br />

E OK<br />

E PAR<br />

Normal completion<br />

Parameter error (tskpri is invalid)<br />

[Description]<br />

Rotates the precedence among tasks having the priority designated in tskpri.<br />

This system call changes the precedence of tasks in RUN or READY state having the designated priority,<br />

so that the task with the highest precedence among those tasks is given the lowest precedence.<br />

By setting tskpri = TPRI RUN = 0, this system call rotates the precedence of tasks having the priority<br />

level of the task currently in RUN state. When tk rot rdq is called from an ordinary task, it rotates the<br />

precedence of tasks having the same priority as the invoking task. When calling from a cyclic handler<br />

or other task-independent portion, it is also possible to call tk rot rdq (tskpri = TPRI RUN).<br />

[Additional Notes]<br />

If there are no tasks in a run state having the designated priority, or only one such task, the system call<br />

completes normally with no operation (no error code is returned).<br />

When this system call is issued in dispatch enabled state, designating as the priority either TPRI RUN or<br />

the current priority of the invoking task, the precedence of the invoking task will be the lowest among<br />

tasks of the same priority. In this way the system call can be used to relinquish execution privilege.<br />

In dispatch disabled state, the task with highest precedence among tasks of the same priority is not<br />

always the currently executing task. The precedence of the invoking task will therefore not always<br />

become the lowest among tasks having the same priority when the above method is used in dispatch<br />

disabled state.<br />

Examples of tk rot rdq execution are given in Figure 4.9 and Figure 4.10. When this system call is<br />

issued in the state shown in Figure 4.9 designating tskpri = 2, the new precedence order becomes that<br />

in Figure 4.10, and Task C becomes the executing task.<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!