Operating Systems and Embedded Software · Kernel
Real-Time Scheduling
Also known as RT scheduling, SCHED_FIFO, SCHED_RR, SCHED_DEADLINE, PREEMPT_RT, EDF scheduling
Scheduling that orders work so tasks meet timing constraints such as deadlines and bounded latency, using fixed priorities or deadline-based algorithms, together with analysis showing the constraints hold in the worst case.
Explanation
Real-time scheduling is about determinism rather than speed: each task must get enough CPU time, early enough, to meet its deadline even under worst-case load. The two common approaches are fixed-priority preemptive scheduling, in which the most urgent ready task always runs, and earliest-deadline-first (EDF), in which the task with the nearest absolute deadline runs.
Linux offers SCHED_FIFO and SCHED_RR, with static priorities 1 to 99 that always rank above normal threads. Since Linux 3.14 it also offers SCHED_DEADLINE, which combines EDF with a Constant Bandwidth Server (CBS): a task declares a runtime, deadline and period, and admission control rejects task sets that would overload the CPUs. The PREEMPT_RT configuration makes most of the kernel preemptible, using sleeping spin locks with priority inheritance and threaded interrupts, so kernel activity delays high-priority tasks less.
Policies alone guarantee nothing. Designers also need worst-case execution times, bounded blocking, budgets for interrupts and memory contention, and schedulability analysis. On multicore SoCs, shared caches and buses make worst-case timing harder to bound.
How it works
With fixed priorities, the scheduler preempts lower-priority work as soon as a higher-priority task becomes ready. SCHED_FIFO tasks of equal priority run until they block or yield, while SCHED_RR tasks take turns using a time quantum. With SCHED_DEADLINE, each job receives up to its runtime budget in every period; the CBS throttles a task that overruns its budget so it cannot disturb others, and EDF orders tasks by their current deadlines.
Automotive applications
- Sensor acquisition and control loops on Linux-based ECUs
- Audio and display pipelines with strict frame timing
- Time-critical callbacks in ROS 2 systems
- Partitioning CPU bandwidth between mixed-criticality tasks
Example
A LiDAR driver thread must process a packet batch every 10 ms in at most 2 ms. With SCHED_DEADLINE parameters of runtime 2 ms, deadline 10 ms and period 10 ms, the kernel admits the task only if the total reserved bandwidth fits, and throttles it if it overruns.
An illustrative example: any figures in it are worked numbers, not measurements.
References
- Deadline Task Scheduling (opens in a new tab)
“The SCHED_DEADLINE policy contained inside the sched_dl scheduling class is basically an implementation of the Earliest Deadline First (EDF) scheduling algorithm”
- sched(7): overview of CPU scheduling (opens in a new tab)
- Real-time preemption: Theory of operation (opens in a new tab)
“PREEMPT_RT transforms the Linux kernel into a real-time kernel.”
Definitions are original summaries. Standards text is not reproduced; follow the links for the official publications.