Consider a set of 5 processes whose arrival time, CPU time needed and the…
2009
Consider a set of 5 processes whose arrival time, CPU time needed and the priority are given below:
Process Arrival Time CPU Time Needed Priority
(in ms)
P1 0 10 5
P2 0 5 2
P3 2 3 1
P4 5 20 4
P5 10 2 3(smaller the number, higher the priority) If the CPU scheduling policy is priority scheduling without preemption, the average waiting time will be
- A.
12.8 ms
- B.
11.8 ms
- C.
10.8 ms
- D.
9.8 ms
Attempted by 116 students.
Show answer & explanation
Correct answer: C
At T=0, P2 (priority 2) starts before P1 (priority 5). At T=5, P3 (priority 1) arrives and has higher priority than P1 or P4, so it runs until T=8. At T=8, P4 (priority 4) has higher priority than P1, running until T=28. At T=28, P5 (priority 3) runs before P1, finishing at T=30. Finally, P1 runs from T=30 to 40. Waiting times: P1(30), P2(0), P3(3), P4(3), P5(18). Total = 54 ms. Average = 54/5 = 10.8 ms.
A video solution is available for this question — log in and enroll to watch it.