The idea: let the deadline set the priority
A real-time system runs periodic tasks: every T ticks a task releases a job that needs C ticks of CPU before its deadline, here the next release. Rate-monotonic scheduling gives each task one fixed priority, shorter period first, and proves on paper whether every deadline is met. Its set B, τ1 (C = 2, T = 5) and τ2 (C = 4, T = 7), fails: the CPU is busy only 97.1% of the time (U = 2/5 + 4/7 = 0.971), yet τ2 misses its deadline at tick 7. This page runs the same jobs under two dynamic-priority rules, where each job's priority comes from its own deadline, and counts what each rule costs.
Earliest deadline first
Earliest deadline first (EDF) gives the CPU, at every tick, to the ready job with the nearest absolute deadline. A task has no fixed rank: τ1's job due at 10 loses to τ2's job due at 7, but τ1's job due at 20 beats τ2's job due at 21. On set B (Demo: EDF meets every deadline, set B) the critical moment is tick 5. τ1 releases its second job with deadline 10, while τ2's first job, due at 7, has one tick left. EDF keeps τ2, which finishes at 6, and τ1 runs 6–7, well before 10. Over the whole hyperperiod H = lcm(5, 7) = 35 ticks no job is late, the CPU is idle only at tick 34, and there are just 2 preemptions. Under RM (Demo: RM misses on set B) the same jobs give one miss and 5 preemptions.
This is no luck. Liu and Layland proved in 1973 that on one CPU, with deadlines equal to periods, EDF meets every deadline if and only if U = Σ C/T ≤ 1. No other scheduler can do better: if any order of the jobs works, EDF finds one. Fixed priorities only guarantee success under a lower bound (0.828 for two tasks); between that and 1 they may fail, as set B shows.
Least slack time
The slack (or laxity) of a job is how long it can still wait and finish in time: slack = d − t − C left, the deadline minus now minus the work left. Least slack time (LST, also called least laxity first) runs the job with the smallest slack. It is optimal on one CPU too, and it meets every deadline of set B (Demo: least slack, set B). The catch is that slack changes all the time. A waiting job's slack falls by one each tick; the running job's slack stays the same, because it does one tick of work in one tick of time. So two jobs with close slack keep overtaking each other, and the scheduler must recompute slack every tick.
Counting preemptions
A preemption here means the job that ran in the last tick is unfinished and another job takes the CPU. Each one costs a context switch and cold caches on a real machine. On the same 35 ticks of set B (Demo: compare RM, EDF, LST on set B):
| policy | deadline misses | preemptions | priority computed |
|---|---|---|---|
| RM | 1 (τ2 at 7) | 5 | once per task, offline |
| EDF | 0 | 2 | once per job, at its release |
| LST | 0 | 8 | every tick, for every ready job |
EDF often preempts less than RM, because a newly released job usually has a later deadline than the one already running. LST pays for its constant re-ranking with extra switches, which is why real systems use EDF and not LST.
Overload and the domino effect
EDF's guarantee stops at U = 1. Set O asks for more than the CPU has: τ1 (C = 2, T = 3), τ2 (2, 6) and τ3 (2, 10), U = 2/3 + 1/3 + 1/5 = 1.2. On the page a late job is not dropped; it keeps running, as an overrunning task would. Under EDF a late job has the earliest deadline of all, because its deadline is already in the past. So it runs first and pushes the next jobs past their own deadlines, which then run first in turn: the domino effect (Demo: overload, EDF domino effect). The first miss is τ2 at 12, and by tick 30 there are 11 misses spread over all three tasks. Least slack behaves the same way, with 13 misses. Rate-monotonic misses only 3 deadlines, all of τ3 (Demo: overload, RM sheds τ3 only): τ1 and τ2 together use 2/3 + 2/6 = 1 of the CPU, so τ3 never runs, but the two higher-priority tasks never notice the overload.
Which one to use
- EDF when the load is known to stay at or below 1 and the CPU should be used fully. Linux offers it as
SCHED_DEADLINE, with an admission test that refuses tasks that would push U past the limit, so overload cannot happen. - Fixed priorities (RM) when an overload must be possible but should hurt only the least important task. Most RTOS kernels work this way, and the analysis is on the rate-monotonic page.
- LST mostly as a teaching tool and in some multiprocessor schemes; on one CPU it gives nothing EDF does not, at the price of more switches.
See also real-time scheduling on Linux (SCHED_FIFO, SCHED_RR and priority inversion), CPU scheduling (FCFS, SJF, round robin and CFS for ordinary processes), the cyclic executive, which fixes the whole schedule in a table before the system runs, and priority ceiling and the stack resource policy for tasks that share locks.
See also a time-triggered co-operative scheduler, the simpler non-preemptive way small microcontrollers run periodic tasks from one timer tick.
See also embedded software architectures for where fixed-priority preemption fits among simpler designs such as the super loop and the function queue.
What the page leaves out
One CPU, whole ticks, every task released at t = 0, deadlines equal to periods, and context switches that cost nothing. Tasks never block or share resources. A real LST scheduler would have to track slack continuously, not once per tick. The page does not cover the processor-demand test for deadlines shorter than periods, overload handling for EDF (dropping or skipping jobs, as in the RED and D-over algorithms), constant-bandwidth servers, or multiprocessor EDF.