Question 18Asked in UGC NET Computer Science, August 2016 (Paper II & III, Selected Questions)

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).
  1. A3
  2. B2
  3. C4
  4. D5
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.

From UGC NET Computer Science PYQ, August 2016 (Paper II & III, Selected Questions)

This is question 18 of UGC NET Computer Science PYQ, August 2016 (Paper II & III, Selected Questions). See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.