Consider three CPU intensive processes P1, P2, P3 which require 20, 10 and 30 units of time, arrive at times 1, 3 and 7 respectively. Suppose operating…
Consider three CPU intensive processes P1, P2, P3 which require 20, 10 and 30 units of time, arrive at times 1, 3 and 7 respectively. Suppose operating system is implementing shortest Remaining time first (preemptive scheduling) algorithm, then .............. context switches are required (suppose context switch at the beginning of ready queue and at the end of Ready queue are not counted).
Show answerHide answer
Correct answer: (A) 3
Explanation
P1 arrives at time 1 and runs. At time 3, P2 arrives with a shorter remaining time (10 < 18), so there is a switch to P2 (1). P2 runs to completion at time 13 since no shorter job arrives, then there is a switch to P1 (2). P1 (remaining 18) runs to completion since its remaining time is less than P3's burst time (30), then there is a switch to P3 (3), which runs to completion. So 3 context switches are required.