Exercises — Real-time constraints — hard and soft deadlines
This page is a self-testing ladder. Each problem sits at a difficulty level (L1 → L5). Read the problem, cover the solution, try it, then open the collapsible [!recall]- to check. Every number here is machine-verified.
Prerequisite ideas live on the parent note the topic note and its neighbours: Rate-Monotonic Scheduling, Earliest Deadline First (EDF), Worst-Case Execution Time analysis, Priority Inversion and Priority Inheritance, RTOS scheduler design, Periodic vs Aperiodic Tasks, Jitter and Latency.
Level 1 — Recognition
L1.1 — Classify the deadline
For each system, state whether the timing requirement is hard, firm, or soft, and justify by the value of a late result.
(a) A car's airbag controller must fire within 20 ms of a crash. (b) A video decoder produces frame 900; it arrives 5 ms after its display slot. (c) A music streaming app's buffer refill runs a few milliseconds late.
Recall Solution
The rule: look at the utility of a result delivered after the deadline.
- (a) Hard. A late airbag is catastrophic — the value of a late result is effectively . This is a total system failure, not slowness.
- (b) Firm. A video frame that misses its display slot has zero value (you can't show it), so you discard it — but nothing breaks. Late value = 0, no catastrophe.
- (c) Soft. A slightly late buffer refill degrades quality (a tiny stutter) but the result still has reduced value; occasional misses are tolerated.
L1.2 — Read off the utilisation
A single periodic task has ms and ms. What fraction of the CPU does it demand?
Recall Solution
Why this formula? In every window of ms the task needs ms of CPU, so it occupies of the processor on average. It leaves of the CPU free.
Level 2 — Application
L2.1 — Total utilisation of a task set
Tasks: ; ; . Compute the total utilisation .
Recall Solution
Why sum? All three tasks share one CPU, and their demands are additive fractions of that single resource. Since the CPU is not over-subscribed — a necessary (not yet sufficient) condition to be schedulable.
L2.2 — Compute the Rate-Monotonic bound
For a set of tasks, compute the Liu–Layland utilisation bound .
Recall Solution
Why below 1? Under fixed priorities the worst-case phasing (all tasks released together) sometimes forces the CPU to idle even when work exists, so you cannot safely fill it to . For the safe ceiling is about .
L2.3 — Apply the RM test
Is the task set from L2.1 () schedulable under Rate-Monotonic scheduling?
Recall Solution
Compare against the bound from L2.2: Yes — RM guarantees every deadline. Passing a sufficient test is a proof of schedulability; we are done and don't need any exact test.
Level 3 — Analysis
L3.1 — When the bound fails but the set is fine
Tasks: ; ; . (a) Compute . (b) Does it pass the RM bound for ? (c) What does failing the bound prove?
Recall Solution
(a) . (b) RM bound . Since , it fails the utilisation test. (c) Failing proves nothing about unschedulability. The Liu–Layland bound is sufficient, not necessary: passing guarantees success, but failing is inconclusive. To decide, run the exact Response-Time Analysis (see L4).
L3.2 — EDF versus RM on the same set
For the set in L3.1 (), is it schedulable under EDF? Why does EDF succeed where the RM utilisation test was inconclusive?
Recall Solution
EDF's exact bound (with ) is . Here , so EDF schedules it. Why EDF wins: EDF always runs the job with the earliest absolute deadline first, dynamically re-prioritising. This never wastes CPU on worst-case phasing, so it can safely use the whole processor. RM's fixed priorities can't, which is exactly why RM's sufficient bound sits below 1.
The next figure makes the RM-versus-EDF gap visual. Read it like this: the horizontal axis is the number of tasks ; the vertical axis is the highest utilisation each policy can safely accept. The black flat line at is the EDF ceiling — EDF can always fill the CPU completely. The red curve is the RM bound : it starts at for a single task, then sags, crossing the dashed marker that it approaches as . The red dot marks our L3 set at — it sits above the red RM ceiling (so RM's utilisation test is inconclusive) but below the black EDF line (so EDF schedules it). The insight: choosing EDF buys you the whole gap between the red curve and the black line.

Level 4 — Synthesis
L4.1 — Exact Response-Time Analysis
Tasks (deadline = period), priorities by RM (shorter period = higher priority): ; ; . Use the iteration to find (the response time of the lowest-priority task) and decide if it meets its deadline .
Recall Solution
Task 3 has the longest period, so it is lowest priority; the higher-priority set is (both preempt it). The ceiling counts how many times task interrupts task 3 within the window .
Start: .
Iteration 1:
Iteration 2:
Iteration 3:
Iteration 4:
Iteration 5:
Converged at . Now test: → task 3 MISSES its deadline. The set is not RM-schedulable, even though (check) .
Why iterate? appears on both sides: a longer response window admits more preemptions, which lengthens the window again. We repeat until the value stops changing (a fixed point), which is the true worst-case response time.
The timeline figure below shows why stretches to . Time (ms) runs left to right. The top row (T1) shows task 1's releases at , each a -ms block of CPU it grabs ahead of task 3. The middle row (T2) shows task 2's releases at , again -ms blocks with priority over task 3. The bottom red row (T3) is task 3's own ms of work — but every higher-priority block above pushes it later, so its completion is dragged all the way to (the solid red line). The dashed black line is the deadline : because the red completion line lands to the right of it, task 3 misses. The picture makes concrete what the ceilings counted: preemptions eat the gaps and stretch the response window past the deadline.

Level 5 — Mastery
L5.1 — Design a schedulable set under a utilisation budget
You must add a third task to ; so that all three pass the RM utilisation bound for (which is ). The new task has . What is the largest integer (in ms) you may choose?
Recall Solution
Fixed part: . Budget left: . Allowed : solve . Largest integer: . Check: with , ✅. With , , fails. So the answer is ms.
L5.2 — Hard vs soft design decision
A drone flight-control loop and a telemetry-logging task share one MCU. The flight loop has a hard deadline; the logger a soft one. Under overload, which task should shed work, and what design principle governs this?
Recall Solution
The soft telemetry logger sheds work — drop or down-sample log entries, or skip a cycle. The flight-control loop's hard deadline must never be compromised because a miss is catastrophic. Principle: graceful degradation — under overload you degrade the low-value soft tasks to protect the high-value hard tasks. This is a scheduling/priority design choice; give the hard task guaranteed CPU (e.g. highest RM priority + priority inheritance on shared locks) and make the soft task best-effort.
Recall Feynman check: say the whole ladder in one breath
First you name the deadline type (L1), then measure CPU demand (L2), then judge it against the right bound — for RM, for EDF — knowing that failing the RM bound only means "unknown, run the exact test" (L3). The exact test is the iterating Response-Time equation, which converges to the true worst case (L4). Finally you design within budget and protect hard tasks by degrading soft ones (L5).