CS FundamentalsVery hardGATE CS (PYQ pattern)

Four processes with CPU bursts 10, 4, 2 and 1 ms arrive together at time 0 in that order and are scheduled by Round Robin with quantum 3 ms. A context switch is counted only when the CPU is handed from one process to a DIFFERENT process (a process that gets the CPU again immediately, because it is the only one left, costs none), and none is counted at the start or end. How many context switches occur?

  1. A. 7
  2. B. 8
  3. C. 6
  4. D. 4

Correct answer: C. 6

Dispatches = ceil(10/3) + ceil(4/3) + ceil(2/3) + ceil(1/3) = 4 + 2 + 1 + 1 = 8, i.e. 7 gaps. P1 runs its last quanta alone once the others finish, so those gaps are not switches; simulating the queue gives 6 real switches.

More Operating Systems questions

Exams that ask this topic