CHAPTER 4 TASK DEPENDENT SYNCHRONIZATION FUNCTIONS
A task is moved to the sleeping state (waiting forever) by issuing the following service call from the processing program.
- slp_tsk
As a result, the invoking task is unlinked from the ready queue and excluded from the RI850V4 scheduling subject.
If a wakeup request has been queued to the target task (the wakeup request counter is not set to 0x0) when this service call is issued, this service call does not move the state but decrements the wakeup request counter (by subtracting 0x1 from the wakeup request counter).
The sleeping state is cancelled in the following cases, and then moved to the READY state.
As a result, the invoking task is unlinked from the ready queue and excluded from the RI850V4 scheduling subject.
If a wakeup request has been queued to the target task (the wakeup request counter is not set to 0x0) when this service call is issued, this service call does not move the state but decrements the wakeup request counter (by subtracting 0x1 from the wakeup request counter).
The sleeping state is cancelled in the following cases, and then moved to the READY state.
#include <kernel.h> /*Standard header file definition*/ #include <kernel_id.h> /*System information header file definition*/ void task (VP_INT exinf) { ER ercd; /*Declares variable*/ ......... ......... ercd = slp_tsk (); /*Put task to sleep (waiting forever)*/ if (ercd == E_OK) { ......... /*Normal termination processing*/ ......... } else if (ercd == E_RLWAI) { ......... /*Forced termination processing*/ ......... } ......... ......... |
A task is moved to the sleeping state (with timeout) by issuing the following service call from the processing program.
- tslp_tsk
This service call moves an invoking task from the RUNNING state to the WAITING state (sleeping state).
As a result, the invoking task is unlinked from the ready queue and excluded from the RI850V4 scheduling subject.
If a wakeup request has been queued to the target task (the wakeup request counter is not set to 0x0) when this service call is issued, this service call does not move the state but decrements the wakeup request counter (by subtracting 0x1 from the wakeup request counter).
The sleeping state is cancelled in the following cases, and then moved to the READY state.
This service call moves an invoking task from the RUNNING state to the WAITING state (sleeping state).
As a result, the invoking task is unlinked from the ready queue and excluded from the RI850V4 scheduling subject.
If a wakeup request has been queued to the target task (the wakeup request counter is not set to 0x0) when this service call is issued, this service call does not move the state but decrements the wakeup request counter (by subtracting 0x1 from the wakeup request counter).
The sleeping state is cancelled in the following cases, and then moved to the READY state.
#include <kernel.h> /*Standard header file definition*/ #include <kernel_id.h> /*System information header file definition*/ void task (VP_INT exinf) { ER ercd; /*Declares variable*/ TMO tmout = 3600; /*Declares and initializes variable*/ ......... ......... ercd = tslp_tsk (tmout); /*Put task to sleep (with timeout)*/ if (ercd == E_OK) { ......... /*Normal termination processing*/ ......... } else if (ercd == E_RLWAI) { ......... /*Forced termination processing*/ ......... } else if (ercd == E_TMOUT) { ......... /*Timeout processing*/ ......... } ......... ......... } |
Note When TMO_FEVR is specified for wait time tmout, processing equivalent to slp_tsk will be executed.
- wup_tsk, iwup_tsk
These service calls cancel the WAITING state (sleeping state) of the task specified by parameter tskid.
As a result, the target task is moved from the sleeping state to the READY state, or from the WAITING-SUSPENDED state to the SUSPENDED state.
If the target task is in a state other than the sleeping state when this service call is issued, this service call does not move the state but increments the wakeup request counter (by added 0x1 to the wakeup request counter).
The following describes an example for coding this service call.
These service calls cancel the WAITING state (sleeping state) of the task specified by parameter tskid.
As a result, the target task is moved from the sleeping state to the READY state, or from the WAITING-SUSPENDED state to the SUSPENDED state.
If the target task is in a state other than the sleeping state when this service call is issued, this service call does not move the state but increments the wakeup request counter (by added 0x1 to the wakeup request counter).
The following describes an example for coding this service call.
#include <kernel.h> /*Standard header file definition*/ #include <kernel_id.h> /*System information header file definition*/ void task (VP_INT exinf) { ID tskid = ID_TSK1; /*Declares and initializes variable*/ ......... ......... wup_tsk (tskid); /*Wakeup task*/ ......... ......... } |
Note The wakeup request counter managed by the RI850V4 is configured in 7-bit widths. If the number of wakeup requests exceeds the maximum count value 127 as a result of issuing this service call, the counter manipulation processing is therefore not performed but "E_QOVR" is returned.
- can_wup, ican_wup
These service calls cancel all of the wakeup requests queued to the task specified by parameter tskid (the wakeup request counter is set to 0x0).
When this service call is terminated normally, the number of cancelled wakeup requests is returned.
The following describes an example for coding this service call.
These service calls cancel all of the wakeup requests queued to the task specified by parameter tskid (the wakeup request counter is set to 0x0).
When this service call is terminated normally, the number of cancelled wakeup requests is returned.
The following describes an example for coding this service call.
#include <kernel.h> /*Standard header file definition*/ #include <kernel_id.h> /*System information header file definition*/ void task (VP_INT exinf) { ER_UINT ercd; /*Declares variable*/ ID tskid = ID_TSK1; /*Declares and initializes variable*/ ......... ercd = can_wup (tskid); /*Cancel task wakeup requests*/ if (ercd >= 0x0) { ......... /*Normal termination processing*/ } ......... } |
The WAITING state is forcibly cancelled by issuing the following service call from the processing program.
- rel_wai, irel_wai
These service calls forcibly cancel the WAITING state of the task specified by parameter tskid.
As a result, the target task unlinked from the wait queue and is moved from the WAITING state to the READY state, or from the WAITING-SUSPENDED state to the SUSPENDED state.
"E_RLWAI" is returned from the service call that triggered the move to the WAITING state (slp_tsk, wai_sem, or the like) to the task whose WAITING state is cancelled by this service call.
The following describes an example for coding this service call.
These service calls forcibly cancel the WAITING state of the task specified by parameter tskid.
As a result, the target task unlinked from the wait queue and is moved from the WAITING state to the READY state, or from the WAITING-SUSPENDED state to the SUSPENDED state.
"E_RLWAI" is returned from the service call that triggered the move to the WAITING state (slp_tsk, wai_sem, or the like) to the task whose WAITING state is cancelled by this service call.
The following describes an example for coding this service call.
#include <kernel.h> /*Standard header file definition*/ #include <kernel_id.h> /*System information header file definition*/ void task (VP_INT exinf) { ID tskid = ID_TSK1; /*Declares and initializes variable*/ ......... rel_wai (tskid); /*Release task from waiting*/ ......... } |
Note 1 This service call does not perform queuing of forced cancellation requests. If the target task is in a state other than the WAITING or WAITING-SUSPENDED state, "E_OBJ" is returned.
A task is moved to the SUSPENDED state by issuing the following service call from the processing program.
- sus_tsk, isus_tsk
These service calls add 0x1 to the suspend request counter for the task specified by parameter tskid, and then move the target task from the RUNNING state to the SUSPENDED state, from the READY state to the SUSPENDED state, or from the WAITING state to the WAITING-SUSPENDED state.
If the target task has moved to the SUSPENDED or WAITING-SUSPENDED state when this service call is issued, the counter manipulation processing is not performed but only the suspend request counter increment processing is executed.
The following describes an example for coding this service call.
These service calls add 0x1 to the suspend request counter for the task specified by parameter tskid, and then move the target task from the RUNNING state to the SUSPENDED state, from the READY state to the SUSPENDED state, or from the WAITING state to the WAITING-SUSPENDED state.
If the target task has moved to the SUSPENDED or WAITING-SUSPENDED state when this service call is issued, the counter manipulation processing is not performed but only the suspend request counter increment processing is executed.
The following describes an example for coding this service call.
#include <kernel.h> /*Standard header file definition*/ #include <kernel_id.h> /*System information header file definition*/ void task (VP_INT exinf) { ID tskid = ID_TSK1; /*Declares and initializes variable*/ ......... sus_tsk (tskid); /*Suspend task*/ ......... } |
Note The suspend request counter managed by the RI850V4 is configured in 7-bit widths. If the number of suspend requests exceeds the maximum count value 127 as a result of issuing this service call, the counter manipulation processing is therefore not performed but "E_QOVR" is returned.
- rsm_tsk, irsm_tsk
This service call subtracts 0x1 from the suspend request counter for the task specified by parameter tskid, and then cancels the SUSPENDED state of the target task.
As a result, the target task is moved from the SUSPENDED state to the READY state, or from the WAITING-SUSPENDED state to the WAITING state.
If a suspend request is queued (subtraction result is other than 0x0) when this service call is issued, the counter manipulation processing is not performed but only the suspend request counter decrement processing is executed.
The following describes an example for coding this service call.
This service call subtracts 0x1 from the suspend request counter for the task specified by parameter tskid, and then cancels the SUSPENDED state of the target task.
As a result, the target task is moved from the SUSPENDED state to the READY state, or from the WAITING-SUSPENDED state to the WAITING state.
If a suspend request is queued (subtraction result is other than 0x0) when this service call is issued, the counter manipulation processing is not performed but only the suspend request counter decrement processing is executed.
The following describes an example for coding this service call.
#include <kernel.h> /*Standard header file definition*/ #include <kernel_id.h> /*System information header file definition*/ void task (VP_INT exinf) { ID tskid = ID_TSK1; /*Declares and initializes variable*/ ......... rsm_tsk (tskid); /*Resume suspended task*/ ......... } |
Note This service call does not perform queuing of cancellation requests. If the target task is in a state other than the SUSPENDED or WAITING-SUSPENDED state, "E_OBJ" is therefore returned.
The SUSPENDED state is forcibly cancelled by issuing the following service calls from the processing program.
- frsm_tsk, ifrsm_tsk
These service calls cancel all of the suspend requests issued for the task specified by parameter tskid (by setting the suspend request counter to 0x0). As a result, the target task moves from the SUSPENDED state to the READY state, or from the WAITING-SUSPENDED state to the WAITING state.
The following describes an example for coding this service call.
These service calls cancel all of the suspend requests issued for the task specified by parameter tskid (by setting the suspend request counter to 0x0). As a result, the target task moves from the SUSPENDED state to the READY state, or from the WAITING-SUSPENDED state to the WAITING state.
The following describes an example for coding this service call.
#include <kernel.h> /*Standard header file definition*/ #include <kernel_id.h> /*System information header file definition*/ void task (VP_INT exinf) { ID tskid = ID_TSK1; /*Declares and initializes variable*/ ......... frsm_tsk (tskid); /*Forcibly resume suspended task*/ ......... } |
Note This service call does not perform queuing of cancellation requests. If the target task is in a state other than the SUSPENDED or WAITING-SUSPENDED state, "E_OBJ" is therefore returned.
A task is moved to the delayed state by issuing the following service call from the processing program.
- dly_tsk
This service call moves the invoking task from the RUNNING state to the WAITING state (delayed state).
As a result, the invoking task is unlinked from the ready queue and excluded from the RI850V4 scheduling subject.
The delayed state is cancelled in the following cases, and then moved to the READY state.
This service call moves the invoking task from the RUNNING state to the WAITING state (delayed state).
As a result, the invoking task is unlinked from the ready queue and excluded from the RI850V4 scheduling subject.
The delayed state is cancelled in the following cases, and then moved to the READY state.
#include <kernel.h> /*Standard header file definition*/ #include <kernel_id.h> /*System information header file definition*/ void task (VP_INT exinf) { ER ercd; /*Declares variable*/ RELTIM dlytim = 3600; /*Declares and initializes variable*/ ......... ercd = dly_tsk (dlytim); /*Delay task*/ if (ercd == E_OK) { ......... /*Normal termination processing*/ } else if (ercd == E_RLWAI) { ......... /*Forced termination processing*/ } ......... } |