NivaarExam PrepOfficial exam papers ↗

19-Soft-A4 Real-Time Systems · December 2015

Question 4 of 6: FCFS vs. EDF Scheduling of Four Single-Instance Tasks

Nivaar worked solution (AI-drafted; not reviewed by a licensed engineer)

Notes on this paper

National Exams — December 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/EDF scheduling, priority-driven scheduling of periodic tasks; Giorgio C. Buttazzo, Hard Real-Time Computing Systems: Predictable Scheduling Algorithms and Applications (Springer, 3rd ed.) — RTOS design, EDF optimality, real-time system design examples; Hermann Kopetz, Real-Time Systems: Design Principles for Distributed Embedded Applications (Springer, 2nd ed.) — distributed/embedded real-time system design; Ian Sommerville, Software Engineering (Pearson, 10th ed.) — embedded and critical-systems context; Transportation Association of Canada, Geometric Design Guide for Canadian Roads — perception-reaction time and stopping-sight-distance practice.

Question 4: FCFS vs. EDF Scheduling of Four Single-Instance Tasks (20%)

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. Task arrival times, computation times and absolute deadlines per the table above; FCFS ties (T1, T2 both arrive at t=0) broken by listing order.

Find. (1) The FCFS completion schedule; (2) whether every task meets its deadline under FCFS; (3) the EDF completion schedule and whether it meets every deadline.

Approach. FCFS is non-preemptive and ignores deadlines entirely, so it is simulated by simply running tasks in arrival order to completion. EDF is preemptive: at every instant the ready task with the earliest absolute deadline runs, so it must be simulated event-by-event (every arrival is a potential preemption point).

  1. FCFS schedule. T1 and T2 both arrive at t=0; by listing order T1 runs first. Each subsequent task starts the instant the previous one finishes (its own arrival having already occurred by then). $$\text{T1: } 0\text{-}4 \quad \text{T2: } 4\text{-}7 \quad \text{T3: } 7\text{-}12 \quad \text{T4: } 12\text{-}14$$
    FCFS schedule (non-preemptive, arrival order T1,T2,T3,T4)0123456789101112131415t (ms)T14D=15T23D=12T35D=9T42D=8^ = arrival | (red) = absolute deadline
    Fig. Q4-1 — FCFS schedule. T3's deadline (9) falls inside its own execution window and T4's deadline (8) has already passed before T4 even starts.
  2. Check FCFS against every deadline — does it work? T1 finishes at 4 (deadline 15, MET); T2 finishes at 7 (deadline 12, MET); T3 finishes at 12 but its deadline was 9 (MISSED by 3 ms); T4 finishes at 14 but its deadline was 8 (MISSED by 6 ms). FCFS does not work: it schedules purely by arrival order and is blind to deadlines, so the two tasks with the tightest deadlines (T3, T4) — which also happen to arrive latest — are forced to the back of the queue and both miss.
  3. Re-schedule with EDF. EDF always runs the ready task with the earliest absolute deadline, preempting on every new arrival that has an earlier deadline than the task currently running. $$\text{T2: }0\text{-}2\ (\to\text{T3 arrives, }d{=}9<d_{T2}{=}12,\text{ preempt})\qquad \text{T3: }2\text{-}5\ (\to\text{T4 arrives, }d{=}8<d_{T3}{=}9,\text{ preempt})$$ $$\text{T4: }5\text{-}7\ (\text{completes, no preemption pending})\qquad \text{T3 resumes: }7\text{-}9\qquad \text{T2 resumes: }9\text{-}10\qquad \text{T1: }10\text{-}14$$
    EDF schedule (preemptive, earliest absolute deadline first)0123456789101112131415t (ms)T14D=15T221D=12T332D=9T42D=8^ = arrival | (red) = absolute deadline
    Fig. Q4-2 — EDF schedule. T4 finishes at 7 (deadline 8), T3 at 9 (deadline 9, exactly on time), T2 at 10 (deadline 12), T1 at 14 (deadline 15) — every deadline met.
    Under EDF: T4 finishes at 7 (deadline 8, MET); T3 finishes at 9 (deadline 9, MET exactly, zero slack); T2 finishes at 10 (deadline 12, MET); T1 finishes at 14 (deadline 15, MET). All four deadlines are met — EDF succeeds precisely where FCFS failed, by continuously re-ranking the ready queue on urgency (deadline proximity) instead of arrival order.
TaskFCFS finishFCFS resultEDF finishEDF result
T1 (deadline 15)4Met14Met
T2 (deadline 12)7Met10Met
T3 (deadline 9)12Missed9Met (exact)
T4 (deadline 8)14Missed7Met