19-Soft-A4 Real-Time Systems · May 2013
Nivaar worked solution (AI-drafted; not reviewed by a licensed engineer)
National Exams — May 2013 — 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 (aperiodic) tasks, each with an arrival time $a_i$, a computation time $C_i$ and an absolute deadline $D_i$ (all in ms):
| Task | Arrival $a_i$ | Computation $C_i$ | Absolute deadline $D_i$ |
|---|---|---|---|
| T1 | 0 | 4 | 15 |
| T2 | 0 | 3 | 12 |
| T3 | 2 | 5 | 9 |
| T4 | 5 | 2 | 8 |
Find. (1) The FCFS schedule and timing diagram. (2) Whether FCFS meets every deadline. (3) The EDF schedule and timing diagram, and whether EDF meets every deadline.
Approach. FCFS is non-preemptive: tasks are queued in arrival order (T1 and T2 both arrive at $t=0$; T1 is served first, in the order listed) and each runs to completion once started. EDF is preemptive: at every arrival or completion event, the processor switches to whichever ready task has the earliest absolute deadline.
Part (1) — FCFS schedule. Running each task to completion in arrival order T1→T2→T3→T4:
Part (2) — does FCFS work? No. FCFS runs tasks strictly in arrival order with no regard for urgency, so it lets T1 and T2 — both arriving first but with the loosest deadlines (15 ms, 12 ms) — occupy the CPU while T3 (deadline 9 ms) sits ready and idle from $t=2$ onward, and later T4 (deadline 8 ms, the tightest of all four) waits behind everything. Two of the four tasks, T3 and T4, miss their deadlines. FCFS is deadline-blind and is unsuitable whenever tasks with tight deadlines can arrive after tasks with loose ones.
Part (3) — EDF schedule. At each decision point the scheduler picks the ready task with the smallest absolute deadline, preempting the running task if a more urgent one becomes ready:
| Scheduler | Finish times (T1,T2,T3,T4) | Deadlines met? |
|---|---|---|
| FCFS (non-preemptive, arrival order) | 4, 7, 12, 14 | No — T3 (by 3 ms), T4 (by 6 ms) miss |
| EDF (preemptive, earliest deadline first) | 14, 10, 9, 7 | Yes — all four met |