Skip to main content

Different states of a task

Short answer

Task states: Dormant (not created/terminated), Ready (able to run, queued), Running (executing on CPU), Blocked (waiting for event/I/O/semaphore), Suspended (explicitly stopped). Transitions: Ready→Running (dispatch), Running→Ready (preemption), Running→Blocked (wait), Blocked→Ready (event), Running→Dormant (exit).

Briefly explain the different states of a task.

In an RTOS a task moves between a few states under the control of the scheduler:

 Create -> [Ready] --dispatch--> [Running] --finish--> [Dormant]
              ^  <--pre-empt--       |
              |                      | wait (delay, semaphore, I/O)
              +------ event ---- [Blocked]
  1. Dormant / New: the task's code is in memory, but the task has not been created yet (or it has been deleted/terminated). It is not scheduled.
  2. Ready: the task is able to run and is in the ready queue, waiting for the CPU because a higher-priority task is running.
  3. Running: the CPU is executing the task; in a single-CPU system only one task is running.
  4. Blocked (waiting): the task cannot continue until an event happens, such as an I/O completion, a delay expiring, a semaphore or a message. It leaves the ready queue.
  5. Suspended (in some RTOS): the task is explicitly stopped by a call and resumes only when another task resumes it.

Transitions: ready to running (dispatched by the scheduler), running to ready (pre-empted or time slice over), running to blocked (waits), blocked to ready (event occurs), running to dormant (task ends).

✓ Answer checked by Claude Opus 5.5 (high effort)

All Embedded System chapter 6 questions →