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?
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 . Initial queue at : .
Evaluating Option (D) where :
- : executes for 3 units, terminates at . Ready queue: . Context switch to .
- : runs for 4 units (quantum expires, remaining = 3). Ready queue: . Context switch from to (1st switch ).
- : runs for 4 units (quantum expires, remaining = 3). Ready queue: . Context switch from to .
- : runs for 3 units, terminates at . Ready queue: . Context switch from to (1st switch ).
- : runs for 3 units, terminates at . Ready queue: . Context switch from to (2nd switch ).
- : runs for 3 units, terminates at .
In this execution, there is NO context switch from to (after runs, control passes to in round 1, and in round 2 is the last process to run). However, the problem statement requires exactly one context switch from to . Therefore, the burst times in Option (D) cannot produce the specified context switches.
Option (D)
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.