- 2079 Asoj · 6 marks
Preemptive SJF/SRT scheduling (10, 5, 7 ms)
Short answer
Using SRT scheduling, execution is P2, P4, P2, P3, P1. Waiting times: P1=14, P2=2, P3=7, P4=0 ms. Average waiting time = 5.75 ms, average turnaround time = 11.75 ms.
Three processes with process IDs P1, P2, P3 with estimated completion time 10, 5, 7 ms respectively enter the ready queue together. A new process P4 with estimated completion time 2 ms enters the ready queue after 2 ms. Calculate waiting time and TAT for each process and average waiting time and average TAT. Assume there is no I/O waiting for the processes and preemptive SJF / SRT scheduling.
Preemptive SJF (shortest remaining time first, SRT): at every arrival the scheduler compares the new burst with the remaining time of the running process and runs the smaller. P1, P2, P3 arrive at 0 and P4 at 2 ms.
Gantt chart
| P2 | P4 | P2 | P3 | P1 |
0 2 4 7 14 24
Trace
- 0-2: P2 (5 ms) is shortest and runs.
- 2: P4 (2 ms) arrives; P2 has 3 ms left, so P4 preempts.
- 2-4: P4 finishes. 4-7: P2 finishes its remaining 3 ms.
- 7-14: P3 (7 ms). 14-24: P1 (10 ms).
Calculation
TAT = completion time - arrival time; WT = TAT - burst time.
| Process | AT | BT | CT | TAT = CT - AT | WT = TAT - BT |
|---|---|---|---|---|---|
| P1 | 0 | 10 | 24 | 24 | 14 |
| P2 | 0 | 5 | 7 | 7 | 2 |
| P3 | 0 | 7 | 14 | 14 | 7 |
| P4 | 2 | 2 | 4 | 2 | 0 |
AWT = (14 + 2 + 7 + 0) / 4 = 23/4 = 5.75 ms
ATAT = (24 + 7 + 14 + 2) / 4 = 47/4 = 11.75 ms
Answer: AWT = 5.75 ms, ATAT = 11.75 ms.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Preemptive priority scheduling with P4 (6 ms) · Embedded System, chapter 6 · asked 2×
- Non-preemptive priority scheduling (10, 5, 7 ms) · Embedded System, chapter 6 · asked 2×
- Preemptive priority scheduling (4, 10, 5 ms) · Embedded System, chapter 6 · asked 2×
- Priority and SJF scheduling with P4 and P5 · Embedded System, chapter 6 · asked 2×
- Non-preemptive SJF with P4 arriving · Embedded System, chapter 6 · asked 2×
- Priority scheduling (7, 8, 5 ms) with P4 · Embedded System, chapter 6 · asked 2×
- RR, preemptive priority, preemptive SJF · Operating System, chapter 2
- Avg turnaround: FCFS, RR, SJF, SRT, HRRN · Operating System, chapter 2
- Real-time scheduling; two-processor numerical · Operating System, chapter 2