Question

Consider four processes P, Q, R, and S scheduled on a CPU as per round robin algorithm with a time quantum of 4 units. The processes arrive in the order P, Q, R, S, all at time t = 0. There is exactly one context switch from S to Q, exactly one context switch from R to Q, and exactly two context switches from Q to R. There is no context switch from S to P. Switching to a ready process after the termination of another process is also considered a context switch. Which one of the following is NOT possible as CPU burst time (in time units) of these processes?

Choose one option
Official answer and solution
Official answer
D
From
Official GATE 2022 answer key

Solution

Simulate round robin execution for each candidate set of burst times and count context switches between processes.

Round Robin scheduling with quantum q=4q = 4. Initial queue at t=0t=0: P,Q,R,SP, Q, R, S.

Evaluating Option (D) where P=3,Q=7,R=7,S=3P=3, Q=7, R=7, S=3:

  • t=0t = 0: PP executes for 3 units, terminates at t=3t=3. Ready queue: Q,R,SQ, R, S. Context switch to QQ.
  • t=3t = 3: QQ runs for 4 units (quantum expires, remaining = 3). Ready queue: R,S,QR, S, Q. Context switch from QQ to RR (1st switch Q→RQ \to R).
  • t=7t = 7: RR runs for 4 units (quantum expires, remaining = 3). Ready queue: S,Q,RS, Q, R. Context switch from RR to SS.
  • t=11t = 11: SS runs for 3 units, terminates at t=14t=14. Ready queue: Q,RQ, R. Context switch from SS to QQ (1st switch S→QS \to Q).
  • t=14t = 14: QQ runs for 3 units, terminates at t=17t=17. Ready queue: RR. Context switch from QQ to RR (2nd switch Q→RQ \to R).
  • t=17t = 17: RR runs for 3 units, terminates at t=20t=20.

In this execution, there is NO context switch from RR to QQ (after RR runs, control passes to SS in round 1, and in round 2 RR is the last process to run). However, the problem statement requires exactly one context switch from RR to QQ. Therefore, the burst times in Option (D) cannot produce the specified context switches.

Final answer

Option (D)

Common trap

Overlooking the requirement for a context switch from R to Q.

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2022 Computer Science and Information Technology (CS)
Question
42 of 65
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.