RT Scheduler

ChibiOS/RT implements a strictly priority-based scheduling strategy, the module responsible for threads scheduling is called the scheduler. In this module are also defined the data structures used globally by the RTOS.

Global Settings

The scheduler is affected by the following global settings:

CH_CFG_TIME_QUANTUM Time slice, in system ticks, of the round-robin interval.

The Scheduler

The ChibiOS/RT scheduler is the module responsible for threads scheduling, it also exports a low level API that is used by the other modules in order to implement synchronization primitives of any kind.


  • Very fast synchronous context switch.
  • Intrinsic message passing, the context switch operation always carries a message from the thread being switched out to the thread being switched in.
  • Tightly coupled with Virtual Timers in order to implement a timeout capability for all primitives.

The System Class

ChibiOS/RT is designed to be upgradeable to a multi-core capable RTOS. Because of this all the internal data structures are encapsulated into a single system class. In a single core implementation there is a single system object. When multi core MCUs will become common multiple system instances will be possible.

System class diagram:

System Class

This, diagram of the system class shows the most important classes relationships in ChibiOS/RT:

  • A list of ready threads called ready list.
  • A list of alive threads called registry.
  • A reference to the running thread called current.
  • A list of armed virtual timers.
  • Debug-related information for use from debugger.
  • Time measurement calibration data.
  • Kernel runtime statistics.

The Ready List

The ready list is probably the most important data structure in ChibiOS/RT. It is a closed bidirectional ordered list of threads representing the threads eligible for execution. The list is organized as follow:

Ready List

Note that the current thread is not part of the list, it is pointed by a global pointer.

The Idle Thread

The system always runs a special thread called “idle thread”. This thread has the lowest priority level in the system (one), and is executed only when no other thread is ready for execution.
The purpose of the idle thread is to define what the system does when there is nothing to do, usually it is an empty loop or a loop containing a single, architecture-dependent, “Wait for Interrupt” instruction that stops the CPU until a interrupt is detected. Stopping the CPU can reduce during idle times can reduce the system power consumption.
One important details is that the idle thread can only be in the READY or CURRENT states, it is not allowed to go in any of the sleeping states nor to terminate. The idle thread is automatically created on system initialization and lasts until the system is shut down.