tk_rot_rdq

Rotate Ready Queue

[C Language Interface]

ER ercd = tk_rot_rdq ( PRI tskpri ) ;

[Parameters]

PRI tskpri Task priority

[Return Parameters]

ER ercd Error code

[Error Codes]

E_OK Normal completion

E_PAR Parameter error (tskpri is invalid)

[Description]

Rotates the precedence among tasks having the priority specified in tskpri.

This system call changes the precedence of tasks in RUN or READY state having the specified priority, so that the task with the highest precedence among those tasks is given the lowest precedence.

By setting tskpri = TPRI_RUN = 0, this system call rotates the precedence of tasks having the priority level of the task currently in RUN state. When tk_rot_rdq is called from an ordinary task, it rotates the precedence of tasks having the same priority as the invoking task. When calling from a cyclic handler or other task-independent portion, it is also possible to call tk_rot_rdq (tskpri = TPRI_RUN).

[Additional Notes]

If there are no tasks in a run state having the specified priority, or only one such task, the system call completes normally with no operation (no error code is returned).

When this system call is issued in dispatch enabled state, specifying as the priority either TPRI_RUN or the current priority of the invoking task, the precedence of the invoking task will be the lowest among tasks of the same priority. In this way the system call can be used to relinquish execution privilege.

In dispatch disabled state, the task with highest precedence among tasks of the same priority is not always the currently executing task. The precedence of the invoking task will therefore not always become the lowest among tasks having the same priority when the above method is used in dispatch disabled state.

Examples of tk_rot_rdq execution are given in Figure 4.9 and Figure 4.10. When this system call is issued in the state shown in Figure 4.9 specifying tskpri = 2, the new precedence order becomes that in Figure 4.10, and Task C becomes the executing task.



Figure 4.9: Precedence Before Issuing tk_rot_rdq



  • Task C executes next.

Figure 4.10: Precedence After Issuing tk_rot_rdq (tskpri = 2)

Comments