- 2075 Baisakh · 2+8 marks
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).
| Process | Burst time | Priority |
|---|---|---|
| P1 | 10 | 3 |
| P2 | 1 | 1 |
| P3 | 2 | 3 |
| P4 | 1 | 4 |
| P5 | 5 | 2 |
| 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
| Process | Arrival | Burst | Completion | Turnaround | Waiting |
|---|---|---|---|---|---|
| P1 | 0 | 10 | 10 | 10 | 0 |
| P2 | 0 | 1 | 1 | 1 | 0 |
| P3 | 0 | 2 | 3 | 3 | 1 |
| P4 | 0 | 1 | 4 | 4 | 3 |
| P5 | 0 | 5 | 9 | 9 | 4 |
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
| Process | Arrival | Burst | Completion | Turnaround | Waiting |
|---|---|---|---|---|---|
| P1 | 0 | 10 | 13 | 13 | 3 |
| P2 | 0 | 1 | 1 | 1 | 0 |
| P3 | 0 | 2 | 3 | 3 | 1 |
| P4 | 0 | 1 | 1 | 1 | 0 |
| P5 | 0 | 5 | 6 | 6 | 1 |
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
| Process | Arrival | Burst | Completion | Turnaround | Waiting |
|---|---|---|---|---|---|
| P1 | 0 | 10 | 11 | 11 | 1 |
| P2 | 0 | 1 | 1 | 1 | 0 |
| P3 | 0 | 2 | 7 | 7 | 5 |
| P4 | 0 | 1 | 8 | 8 | 7 |
| P5 | 0 | 5 | 5 | 5 | 0 |
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
| Process | Arrival | Burst | Completion | Turnaround | Waiting |
|---|---|---|---|---|---|
| P1 | 0 | 10 | 12 | 12 | 2 |
| P2 | 0 | 1 | 1 | 1 | 0 |
| P3 | 0 | 2 | 4 | 4 | 2 |
| P4 | 0 | 1 | 2 | 2 | 1 |
| P5 | 0 | 5 | 7 | 7 | 2 |
AWT = 7/5 = 1.4 ms; ATAT = 26/5 = 5.2 ms
Summary
| Algorithm | AWT (ms) | ATAT (ms) |
|---|---|---|
| FCFS | 1.6 | 5.4 |
| SJF | 1 | 4.8 |
| Preemptive priority | 2.6 | 6.4 |
| Round Robin (q = 1) | 1.4 | 5.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)
Related questions
- FCFS, SJF, Priority, RR Gantt; max AWT · Operating System, chapter 2
- Two processors: priority and RR (q=3) · Operating System, chapter 2
- Preemptive priority and SRTF Gantt · Operating System, chapter 2
- RR, preemptive priority, preemptive SJF · Operating System, chapter 2
- Preemptive vs non-preemptive; real-time scheduling · Operating System, chapter 2
- Context switching, 5-state model, MLFQ · Operating System, chapter 2
- Priority and SJF scheduling with P4 and P5 · Embedded System, chapter 6 · asked 2×
- Preemptive priority scheduling with P4 (6 ms) · Embedded System, chapter 6 · asked 2×
- Priority scheduling (7, 8, 5 ms) with P4 · Embedded System, chapter 6 · asked 2×
- Non-preemptive priority scheduling (10, 5, 7 ms) · Embedded System, chapter 6 · asked 2×