19-Soft-A4 Real-Time Systems · May 2015
Nivaar worked solution (AI-drafted; not reviewed by a licensed engineer)
National Exams — May 2015 — 04-Soft-A4 Real-Time Systems. Three-hour, closed-book exam (Casio or Sharp approved calculators only). Format: six questions of equal value (20% each); any five constitute a complete paper and only the first five as they appear in the answer book are marked. All six are solved below for completeness. Where a doubt exists as to interpretation, the candidate is expected to state assumptions — engineering assumptions used below are flagged in check callouts.
Reference texts: Jane W. S. Liu, Real-Time Systems (Prentice Hall, 2000) — task models, timing requirements, FCFS and EDF scheduling; Giorgio C. Buttazzo, Hard Real-Time Computing Systems: Predictable Scheduling Algorithms and Applications (Springer, 3rd ed.) — preemptive dynamic-priority scheduling and the optimality of EDF; Hermann Kopetz, Real-Time Systems: Design Principles for Distributed Embedded Applications (Springer, 2nd ed.) — distributed real-time control, network-induced delay and time-triggered protocols; Katsuhiko Ogata, Modern Control Engineering (Pearson, 5th ed.) — frequency-domain stability, phase margin and delay margin; Ian Sommerville, Software Engineering (Pearson, 10th ed.) — general software-engineering process context.
Question text not reproduced: the examination questions are © Engineers and Geoscientists BC. Open the official past paper (linked at the top of this page) to read the question, then follow the worked solution below.
Given. Four independent, single-instance (non-periodic) tasks with the arrival times, computation times and absolute deadlines tabulated above.
Find. (1) The FCFS schedule and its timing diagram; (2) whether FCFS meets every deadline; (3) the EDF schedule and its timing diagram.
Approach. Simulate both scheduling disciplines directly against the given arrival/computation/deadline data: FCFS runs each task to completion in arrival order (non-preemptive); EDF is preemptive and, at every arrival or completion event, always runs whichever ready task currently has the earliest absolute deadline.
t = 0; ties are broken in listed order (T1 before T2), so the non-preemptive run order is T1, T2, T3, T4:
| Task | Start | Finish | Deadline | Result |
|---|---|---|---|---|
| T1 | 0 | 4 | 15 | met (11 ms early) |
| T2 | 4 | 7 | 12 | met (5 ms early) |
| T3 | 7 (arrived at 2, but CPU busy) | 12 | 9 | MISSED by 3 ms |
| T4 | 12 (arrived at 5, but CPU busy) | 14 | 8 | MISSED by 6 ms |
t=2 with the tightest deadline of the whole set (9 ms) but is queued behind T1 and T2 simply because they happened to arrive first and are already running/queued; by the time the CPU reaches T3 at t=7, only 2 ms remain before its deadline but T3 still needs 5 ms of computation, so it necessarily overruns. T4 then inherits the same problem one level worse. Two of four tasks (50%) miss their deadlines under FCFS, even though — as part (3) shows — a feasible schedule for this exact task set exists.t=0: T1(d=15), T2(d=12) ready → run T2 (earlier deadline).t=2: T3(d=9) arrives; 9 < T2's remaining deadline(12) → preempt, run T3. (T2 has done 2 of its 3 ms.)t=5: T4(d=8) arrives; 8 < T3's deadline(9) → preempt, run T4. (T3 has done 3 of its 5 ms.)t=7: T4 completes (needed only 2 ms) — deadline 8, met with 1 ms to spare. Next-earliest deadline among the ready set is T3(9) → resume T3 (2 ms remaining).t=9: T3 completes — deadline 9, met exactly, zero slack. Next-earliest is T2(12) → resume T2 (1 ms remaining).t=10: T2 completes — deadline 12, met with 2 ms to spare. Only T1 remains → run T1 (4 ms, uninterrupted).t=14: T1 completes — deadline 15, met with 1 ms to spare.| Task | FCFS finish (ms) | FCFS result | EDF finish (ms) | EDF result |
|---|---|---|---|---|
| T1 | 4 | met | 14 | met |
| T2 | 7 | met | 10 | met |
| T3 | 12 | MISSED | 9 | met (zero slack) |
| T4 | 14 | MISSED | 7 | met |