Home / Learn Embedded C / Task States Explained

Task States Explained

The lifecycle a task moves through: ready, running, blocked and suspended.

Quick summaryThe lifecycle a task moves through: ready, running, blocked and suspended.

How to think about this

Typical task state transitionsReady (waiting forscheduler)Running (got the CPU)Blocked (waiting on asemaphore/delay/queu…Blocked task returnsto Ready once its…
Typical task state transitions

The basic idea

An RTOS task moves between a small set of states: Ready (able to run, waiting for the scheduler to pick it), Running (actively executing on the CPU), Blocked (waiting on something, like a semaphore or a delay), and Suspended (not eligible to run at all until explicitly resumed).

Why this comes up

Understanding these states is essential for debugging an RTOS-based system — a task that never runs again might be permanently Blocked waiting on something that is never satisfied, a very common real bug class.

The mechanics

Only one task can be in the Running state per CPU core at any instant; every other ready task waits its turn, and a Blocked task is automatically moved back to Ready once whatever it was waiting for becomes available.

Where it is used

  • RTOS debugging
  • Task lifecycle understanding
  • Diagnosing a task that "never runs"

Try it

Modeling 4 task states as a small state machineC: edit and run

A real RTOS tracks exactly this kind of state per task internally; this is a simplified, single-task walk through the transitions.

Try it: one task's action unblocking another task

Task B stays Blocked until Task A sets the condition it is waiting onC: edit and run

Task B only leaves Blocked once the condition it was waiting on (set by a different task) actually becomes true.

Quick check

1. What does it mean for a task to be in the "Blocked" state?