The idea: the whole schedule is a table, made before the system runs
A priority scheduler decides at run time which job goes next. A cyclic executive decides nothing at run time. Before the system is built, the designer writes a table that says which pieces of work run in each short time slot, the frame. A hardware timer interrupts at the start of every frame. The executive looks up the frame's entry, runs those pieces one after another, and then lets the CPU idle until the next interrupt. After the last frame the table starts again from the top. This is clock-driven (or static, or off-line) scheduling. It is old and very plain, and that is why it is still used where timing must be easy to prove: flight control software, and the fixed partition windows of ARINC 653 avionics systems.
Hyperperiod, frames and the task set
The page uses four periodic tasks, written as (period T, execution time C) in ms, each with its deadline D equal to its period: T1 = (4, 1), T2 = (5, 1.8), T3 = (20, 1) and T4 = (20, 2). They are the classic example in Jane Liu's textbook. Their pattern repeats every hyperperiod H, the least common multiple of the periods: lcm(4, 5, 20) = 20 ms. In 20 ms there are 5 + 4 + 1 + 1 = 11 jobs, with 5 + 7.2 + 1 + 2 = 15.2 ms of work, so the CPU is busy 76 % of the time (U = 0.76). The hyperperiod is cut into F frames of size f, so H = F × f. Some books call H the major cycle and f the minor cycle.
The three frame-size rules
A frame is the smallest unit the executive controls: it gets control back only at frame boundaries. So f cannot be chosen freely. It must pass three rules (Demo: the three rules for f = 1 to 5):
- f ≥ the largest C. Every job fits in one frame, so no job must be cut just because frames are short.
- f divides H. The hyperperiod is a whole number of frames, so the table can start again on a frame boundary.
- 2f − gcd(f, T) ≤ D for every task. Between any release of the task and its deadline there is at least one whole frame. A job released just after a frame starts must wait for the next frame; gcd(f, T) is the smallest gap that can occur between a frame start and a release.
| f | rule 1: f ≥ 2 | rule 2: 20 mod f | rule 3: T1 / T2 / T3 / T4 against D = 4 / 5 / 20 / 20 | result |
|---|---|---|---|---|
| 1 ms | ✗ | 0 ✓ | 1 / 1 / 1 / 1 ✓ | ✗ rule 1 |
| 2 ms | ✓ | 0 ✓ | 2 / 3 / 2 / 2 ✓ | ✓ the only one |
| 3 ms | ✓ | 2 ✗ | 5 ✗ / 5 / 5 / 5 | ✗ rules 2 and 3 |
| 4 ms | ✓ | 0 ✓ | 4 / 7 ✗ / 4 / 4 | ✗ rule 3 for T2 |
| 5 ms | ✓ | 0 ✓ | 9 ✗ / 5 / 5 / 5 | ✗ rule 3 for T1 |
f = 4 is the instructive failure. It is long enough and divides 20, but 2 × 4 − gcd(4, 5) = 7 > 5. Concretely, T2's second job is released at 5 ms, just after the frame that starts at 4 ms, and is due at 10 ms. The next whole frame is 8–12 ms, which ends after the deadline. With f = 2 the same job has the frame 6–8 ms. Larger frames (10 and 20 ms) also fail rule 3, for T1.
Building the table, and slicing a job
With f = 2 there are F = 10 frames. The page fills them one at a time (Demo: build the table for f = 2). For frame k, from 2k to 2k + 2 ms, a job is a candidate if it is released by 2k and due at 2k + 2 or later, so it can run anywhere in the frame. Candidates are taken earliest deadline first and placed whole when they fit. The result:
| frame | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
|---|---|---|---|---|---|---|---|---|---|---|
| slices | T1 T3 | T2 | T1 T4a | T2 | T1 T4b | T2 | T1 | – | T1 | T2 |
| slack, ms | 0 | 0.2 | 0 | 0.2 | 0 | 0.2 | 1 | 2 | 1 | 0.2 |
In frame 2, T1's second job takes 1 ms and T4 needs 2 ms, but only 1 ms is left. T4's code is written in two parts, so the table slices it: T4a (1 ms) runs in frame 2 and T4b (1 ms) in frame 4. A slice is a piece of a job that runs from start to end inside one frame; the job is "preempted" only at a frame boundary, and only where the designer planned it. Slicing has a price: the job's state must survive between the parts, and its code must be split by hand. T2 is not sliced: after its 1.8 ms, 0.2 ms are left in its frame, and that is slack. The slack of all frames adds up to 4.8 ms = 20 − 15.2. Real tools find tables with a search or network-flow algorithm (Liu, section 5.5); a greedy fill like this one can fail for task sets where a search would succeed.
The executive at run time
At frame n the timer interrupt fires at 2n ms. The executive first checks that the last frame's work is finished. Then it computes k = n mod F and runs the slices of table[k] in order. When they are done it serves aperiodic work in the remaining slack, and otherwise idles (Demo: one hyperperiod, frame by frame: 12 slices, 0 overruns, 4.8 ms idle). There is no ready queue, no priority, and no context switch inside a frame. Frame 10, at 20 ms, has k = 0 and runs table[0] again (Demo: the second hyperperiod repeats). Because the table is fixed, the exact time every job runs is known in advance, and testing one hyperperiod tests the system.
The time-triggered co-operative scheduler is a close relative. It also has one timer and tasks that run to completion, but it keeps per-task counters (Delay, Period) instead of a full table. The embedded software architectures page puts both next to the round-robin super loop and an RTOS.
Frame overruns
The table assumes each job takes at most its C. If a job runs longer, its slice is still running when the next frame interrupt comes. That is a frame overrun, and the executive must do something about it. On the page, T2's second job takes 2.4 ms instead of 1.8 ms in frame 3 (6–8 ms). Two common choices:
- Abort the job and log the error (Demo: T2 overruns frame 3, abort it). The overrun is found at 8 ms, T2's job 2 is dropped, and frame 4 starts on time. The cost: that job had only 0.4 ms left and would have met its deadline at 10 ms.
- Let it run on and start the next slices late (Demo: T2 overruns frame 3, let it run on). T2 ends at 8.4 ms, frame 4's T1 and T4b then end at 10.4 ms, past the next interrupt, and frame 5's T2 ends at 12.2 ms. So there are overruns at 8, 10 and 12 ms. Frame 6 has 1 ms of slack and absorbs the 0.2 ms delay: it idles from 13.2 ms. No deadline is missed here, but three frames ran late.
A third choice is to suspend the job and finish it later in slack. Either way the overrun is a fault in the design or the timing measurements, and many systems also arm a watchdog timer that resets the processor if the executive itself stops reaching its frame interrupts.
Slack and aperiodic jobs
Jobs with no fixed period, such as an operator command, are aperiodic. A cyclic executive runs them only in the slack: after the frame's slices and until the next frame interrupt, where they are cut and wait for the next slack (Demo: an aperiodic job uses the slack). Job A needs 2 ms and arrives at 11 ms, while frame 5's T2 is running. It gets 11.8–12 ms (0.2 ms), 13–14 ms (1 ms, after frame 6's T1) and 14–14.8 ms (frame 7 is empty), and finishes at 14.8 ms: a response time of 3.8 ms. The periodic jobs are not delayed at all. Liu's slack stealing goes one step further: if a frame has slack, the aperiodic job may run first in that frame, which shortens its response time without moving any periodic job past its deadline.
Cyclic executive vs priority scheduling
| cyclic executive | fixed or dynamic priorities | |
|---|---|---|
| decided | before run time, in a table | at run time, by priority or deadline |
| proof of timing | read the table | an analysis: rate-monotonic response times, or the EDF bound U ≤ 1 |
| locks for shared data | none: slices never overlap | needed, with protocols such as priority ceiling and SRP |
| a new task or a changed period | rebuild the whole table | re-run the analysis |
| periods | best when they are harmonic; a period like 4.9 ms makes H huge | any periods |
| aperiodic work | only in slack | a server or background priority |
Locke's 1992 comparison concluded that a fixed-priority executive with rate-monotonic priorities is usually easier to maintain, while the cyclic executive remains attractive where the simplest possible run-time and a fully predictable schedule matter most. How EDF and least-slack-time decide at run time is on EDF vs least slack time; the Linux real-time classes are on real-time scheduling, and the general-purpose schedulers on CPU scheduling.
See also time-triggered communication, where a schedule table made before run time fixes which node may send on the bus in each slot of a TDMA round.
What the page leaves out
One CPU, all tasks released at 0 with D = T, and an executive that takes no time; a real one costs some microseconds per frame, which is added to the frame's load. The table here comes from a greedy fill, not the network-flow search of Liu's book, and only one task may be sliced. Release jitter, the check that a slice's job has really been released, sporadic jobs with hard deadlines and their acceptance test, slack stealing, mode changes that switch to another table, and multiprocessor tables are not shown.