R8C Family General RTOS Concepts
Task management allows programmers to design their software as a number of separate “chunks” of codes with each handling a distinct goal and deadline. This service encompasses mechanism such as scheduler and dispatcher that creates and maintain task objects.
To achieve concurrency in real-time application program, the application is decompose into small, schedulable, and sequential program units known as “Task”. In real-time context, task is the basic unit of execution and is governed by three time-critical properties; release time, deadline and execution time. Release time refers to the point in time from which the task can be executed. Deadline is the point in time by which the task must complete. Execution time denotes the time the task takes to execute.
A task object is defined by the following set of components:
Task Control block (Task data structures residing in RAM and only accessible by RTOS)
Task Stack (Data defined in program residing in RAM and accessible by stack pointer)
Task Routine (Program code residing in ROM)
Figure 8 Typical Task Control Block (TCB)
Each task may exist in any of the four states, including running, ready, or blocked and dormant as shown in Figure 9. During the execution of an application program, individual tasks are continuously changing from one state to another. However, only one task is in the running mode (i.e. given CPU control) at any point of the execution. In the process where CPU control is change from one task to another, context of the to-be-suspended task will be saved while context of the to-be-executed task will be retrieved. This process of saving the context of a task being suspended and restoring the context of a task being resumed is called context switching.
Figure 9 Possible States Transition of Tasks
Page 8 of 18