
CHAPTER 4 TASK MANAGEMENT
User’s Manual U14833EJ2V0UM
34
4.2
Creating Tasks
Tasks are created by issuing the service calls cre_tsk and acre_tsk. With acre_tsk, assignment of the ID number
can be performed by the kernel. Specifying the static API CRE_TSK enables processing equivalent to cre_tsk to be
performed at system initialization. CRE_TSK also allows activation processing to be performed at the same time as
task creation.
In task creation processing, the kernel recognizes data (text) expanded in the memory as a task and places that
task under its management. Task creation processing involves securing and initializing the index (ID) block specified
from the task control block array in the system pool, and securing the stack area from the stack pool. Each created
task has a unique ID number. The ID number must be an integer in a range of 1 to 0x7fff, and the maximum number
that can be assigned is the number specified in the CF definition file.
Note that the size of the stack used by a task must be specified when the task is created. For how to calculate this
size, refer to the
RX4000 (
μ
ITRON4.0) Installation User’s Manual (U14834E)
.
4.3
Deleting Tasks
In cases such as when a task has completed processing and restarting that task is no longer necessary, the task
can be put into a non-existent state by issuing del_tsk; a process known as task deletion. It is also possible to perform
task termination and deletion together using the service call exd_tsk. When a task is deleted, its task control block is
invalidated, and can be used for a newly created task. Note that when a task is deleted, its stack area is also
released.
4.4
Activating Tasks
Two service calls are supplied in the RX4000 for activating tasks: (i)act_tsk and (i)sta_tsk. (i)act_tsk is used to
retain an activation request.
4.4.1
Activation with activation request retained
When (i)act_tsk is issued, if the target task is in the dormant state, it shifts from the dormant state to the ready
state, becoming subject to scheduling by the kernel. If the target task is in a state other than the dormant (or non-
existent) state, when (i)act_tsk is issued, the activation request is retained, causing the target task to be reactivated as
soon as it has terminated.
The extended data exinf specified when a task is created is passed as the activation parameter for tasks activated
by (i)act_tsk. Note that if TA_ACT is assigned as the attribute of a task created by the static API CRE_TSK, the
activation processing of that task is equivalent to that of act_tsk.
4.4.2
Activation with activation request not retained
(i)sta_tsk is provided in the RX4000 as a task activation method compatible with the
μ
ITRON3.0 specification, in
which tasks are activated without retention of the activation request.
If (i)sta_tsk is issued for a task in the dormant state, the task shifts from the dormant state to the ready state,
becoming subject to scheduling by the kernel. If (i)sta_tsk is issued for a task that is in a state other than dormant, an
error occurs, and the activation request is not retained.
For tasks activated by (i)sta_tsk, the VP_INT type data (4 bytes), which was specified as the (i)sta_tsk parameter,
can be received as the task activation code instead of the extended data exinf.