Consider the following three processes with their arrival times and CPU burst…
2021
Consider the following three processes with their arrival times and CPU burst times (in milliseconds):
P1: Arrival Time = 0, Burst Time = 8
P2: Arrival Time = 1, Burst Time = 4
P3: Arrival Time = 2, Burst Time = 9
What is the average waiting time if these processes are scheduled using the Preemptive Shortest Job First (SJF) scheduling algorithm?
- A.
5.5
- B.
2.66
- C.
4.66
- D.
6
Attempted by 131 students.
Show answer & explanation
Correct answer: C
Key idea: use preemptive shortest-job-first (shortest remaining time first): at every arrival choose the process with the smallest remaining CPU time.
Time 0–1: P1 runs (remaining 7 ms).
Time 1–5: P2 arrives at 1 and runs (4 ms), completing at time 5.
Time 5–12: P1 resumes (7 ms), completing at time 12.
Time 12–21: P3 runs (9 ms), completing at time 21.
Completion and waiting times:
P1: arrival 0, burst 8, completion 12 → turnaround = 12 − 0 = 12 ms → waiting = 12 − 8 = 4 ms.
P2: arrival 1, burst 4, completion 5 → turnaround = 5 − 1 = 4 ms → waiting = 4 − 4 = 0 ms.
P3: arrival 2, burst 9, completion 21 → turnaround = 21 − 2 = 19 ms → waiting = 19 − 9 = 10 ms.
Average waiting time = (4 + 0 + 10) / 3 = 14 / 3 ≈ 4.67 ms. Therefore the numeric answer 4.66 (approx) is correct.
A video solution is available for this question — log in and enroll to watch it.