
CHAPTER 4 TASK MANAGEMENT
User’s Manual U14833EJ2V0UM
40
4.10 Task Context
The environment in which the program operates is generally known as the context. In other words, the context
indicates the stack area (space) used by the CPU operation mode or program and the statuses (registers) saved to
the stack during program execution.
In the same way, the environment in which tasks operate is known as the task context. Therefore, when processing
such as service call issuance from a task is performed, it is sometimes called “performing processing from a task
context”. Moreover, when task switching, such as shifting a task to the waiting state, occurs, the value of the register
of when the task was being executed is saved to (or restored from) the stack area. This register value saved in the
stack area is called the task context.
For details of the types of registers that include task contexts and the structures used when contexts are written to
the memory, refer to the
RX4000 (
μ
ITRON4.0) Technical User’s Manual (U14835E)
.
4.11 PID
If PID (Position Independent Data) is used for the code created when the task program is compiled or assembled,
the address that is to be the base of a task when it is created must be assigned as a parameter (gp of the task
creation packet T_CTSK). The assigned address is set in the gp register when the task is activated and saved to or
restored from the context when the task is switched.
Note that this base address is unconditionally set in the gp register regardless of its attribute, etc., and therefore
must be set for programs that reference the gp register. If the gp register is not referenced, set NULL = 0.
4.12 Obtaining Task Information
Task information such as the task status can be obtained by using the service calls ref_tsk, iref_tsk, ref_tst, and
iref_tst. For details of each service call, refer to
CHAPTER 13
.
4.13 Coprocessor
When a task is assigned the attribute TA_COP at creation, thus specifying use of the FPU (coprocessor 1), FCR31
(control/status register of FPU) at activation has the same value as FCR31 of the task executed immediately before
this task is activated. If it is necessary to use FCR31 of the task to be activated, to generalize the processing and
reduce the overhead, instead of using the kernel to perform the processing that sets FCR31, this processing must be
described in the prolog section of the function described as a task.
Also, the number of FPU registers that can be used by tasks with the attribute TA_COP is determined uniformly for
the entire system, and therefore specified according to the configuration of the system (CF definition file). The status
registers required for task execution (CU, FR) are set by the kernel according to the TA_COP attribute and
configuration specifications.
In addition, the FCR31 and FPU registers are included in the context of tasks to which the TA_COP attribute has
been assigned, and are saved/restored when those tasks are switched.