Skip to main content

Real-time scheduling; two-processor numerical

Short answer

Real-time scheduling ensures tasks complete by deadlines. For the two-processor set, average waiting and turnaround times are: FCFS 1.6 ms and 5.4 ms; SJF 1 ms and 4.8 ms; preemptive priority 2.6 ms and 6.4 ms; Round Robin (q=1) 1.4 ms and 5.2 ms. SJF yields the lowest values.

What is the real time scheduling? Consider the following set of process, with the length of the burst time given in milliseconds: (Assume the system has two processors P1 and P2).

ProcessBurst timePriority
P1103
P211
P323
P414
P552
The processes are assumed to have arrived in order p1, p2, p3, p4, p5 all at time 0.
Compute the AWT and ATAT for each of the scheduling algorithms: (1) FCFS (2) SJF (3) Pre-emptive priority (4) RR (q=1) scheduling.

Real-time scheduling is scheduling of tasks that must complete within given deadlines. The correctness of the system depends on both the result and the time at which it is produced. In hard real-time systems a missed deadline is a failure; in soft ones it only degrades quality. Tasks are periodic or aperiodic; algorithms include Rate Monotonic (static, shortest period = highest priority) and Earliest Deadline First (dynamic), using preemptive priority-based dispatching with bounded latency.

Numerical (two processors CPU1 and CPU2)

Assumptions: one shared ready queue; a free CPU takes the next process; all arrive at time 0 in order P1 to P5; priority 1 is highest; SJF is non-preemptive; CPU1 is filled first.

1) FCFS

CPU1
| P1 |
0    10
CPU2
| P2 | P3 | P4 | P5 |
0    1    3    4    9
ProcessArrivalBurstCompletionTurnaroundWaiting
P101010100
P201110
P302331
P401443
P505994

AWT = 8/5 = 1.6 ms; ATAT = 27/5 = 5.4 ms

2) SJF

CPU1
| P2 | P3 | P1 |
0    1    3    13
CPU2
| P4 | P5 |
0    1    6
ProcessArrivalBurstCompletionTurnaroundWaiting
P101013133
P201110
P302331
P401110
P505661

AWT = 5/5 = 1 ms; ATAT = 24/5 = 4.8 ms

3) Preemptive priority

CPU1
| P2 | P1 |
0    1    11
CPU2
| P5 | P3 | P4 |
0    5    7    8
ProcessArrivalBurstCompletionTurnaroundWaiting
P101011111
P201110
P302775
P401887
P505550

AWT = 13/5 = 2.6 ms; ATAT = 32/5 = 6.4 ms

4) Round Robin (q = 1)

CPU1
| P1 | P3 | P5 | P3 | P1 |
0    1    2    3    4    12
CPU2
| P2 | P4 | P1 | P5 |
0    1    2    3    7
ProcessArrivalBurstCompletionTurnaroundWaiting
P101012122
P201110
P302442
P401221
P505772

AWT = 7/5 = 1.4 ms; ATAT = 26/5 = 5.2 ms

Summary

AlgorithmAWT (ms)ATAT (ms)
FCFS1.65.4
SJF14.8
Preemptive priority2.66.4
Round Robin (q = 1)1.45.2

Answer: FCFS 1.6 / 5.4; SJF 1 / 4.8; preemptive priority 2.6 / 6.4; RR (q=1) 1.4 / 5.2 ms (AWT / ATAT). SJF is the best.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Operating System chapter 2 questions →