- A task is also called a thread, is a simple program that thinks it has a CPU all to itself.
- A task consists of a sequentially executable program under a state-control by OS.
- The state information of a task is represented by task state, task structure – its data, objects and resource and task control block.
- The design for real time application involves splitting the work into tasks responsible for a portion of problem.
- Each task has its own priority, its own set of CPU register and its own stack area.
- Thus a task can be defined as an embedded program computational unit that runs on a CPU under the state-control of kernel of an OS. It has a state which at instance defines its status, structure, data, objects and resources and control block.
Each task typically is an infinite loop that can be in any one of five states: dormant, ready, running, waiting (for an event), or ISR (interrupted)
- Dormant: The task has been created and a memory is allotted to its structure but the kernel has not scheduled this task.
- Ready: The created task is ready and has been scheduled by the kernel. This task however is not running because a higher priority task is under execution by the CPU.
- Running: The task has access to all the shared resources required for its execution. The CPU executes the task in this state until an higher priority task requests the CPU for its execution
- Waiting: The task is said to be blocked. In this case the task is waiting for a resource which could be some data being processed by some other task or an external real- world input.
- Interrupted (ISR): Finally, a task is in the ISR state when an interrupt has occurred and the CPU is in the process of servicing the interrupt.
Figure also shows the functions provided by μC/OS-II to make a task move from one state to another.