An operating system uses Shortest Remaining Time first (SRT) process scheduling algorithm. Consider the arrival times and execution times for the following processes: P1(execution 20, arrival 0), P2(execution 25, arrival 15), P3(execution 10, arrival 30), P4(execution 15, arrival 45). What is the total waiting time for process P2?
- A5
- 15
- C40
- D55
Explanation
Trace: P1 runs 0-15 (remaining 5, since P2 arrives at 15 with more remaining work). P1 finishes its remaining 5 units, 15-20. P2 (only one ready) runs 20-30 (10 units, remaining 15) until P3 arrives at 30 with less remaining (10<15), preempting P2. P3 runs 30-40 to completion. P2 resumes 40-45 (5 units, remaining 10) until P4 arrives at 45 with more remaining (15>10), so P2 continues uninterrupted 45-55 to completion. P2's waiting time = completion(55) - arrival(15) - burst(25) = 15.
Source: GATE CS 2007 (2007)
This question is part of a 15-day revision cycle — sign in and Project Forge will bring it back the day before you'd forget it.