GateAI
CPU and I/O Scheduling

GATE CSE 2022 · Q42

MCQ2 marksHard

Time

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?

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: D) P = 3, Q = 7, R = 7, S = 3

CPU and I/O Scheduling

Let us trace the Round Robin scheduling execution order with time quantum TQ=4TQ = 4 for each option:

Initial ready queue at t=0t = 0: [P,Q,R,S][\text{P}, \text{Q}, \text{R}, \text{S}]

Testing Option (A): P=4,Q=10,R=6,S=2\text{P}=4, \text{Q}=10, \text{R}=6, \text{S}=2

  1. P runs for 4 units (00 to 44), terminates. Ready queue: [Q,R,S][\text{Q}, \text{R}, \text{S}]. Switch: P→Q\text{P} \to \text{Q}.

  2. Q runs for 4 units (44 to 88), rem Q=6\text{Q}=6. Ready queue: [R,S,Q][\text{R}, \text{S}, \text{Q}]. Switch: Q→R\text{Q} \to \text{R} (1st Q→R\text{Q} \to \text{R}).

  3. R runs for 4 units (88 to 1212), rem R=2\text{R}=2. Ready queue: [S,Q,R][\text{S}, \text{Q}, \text{R}]. Switch: R→S\text{R} \to \text{S}.

  4. S runs for 2 units (1212 to 1414), terminates. Ready queue: [Q,R][\text{Q}, \text{R}]. Switch: S→Q\text{S} \to \text{Q} (1st S→Q\text{S} \to \text{Q}).

  5. Q runs for 4 units (1414 to 1818), rem Q=2\text{Q}=2. Ready queue: [R,Q][\text{R}, \text{Q}]. Switch: Q→R\text{Q} \to \text{R} (2nd Q→R\text{Q} \to \text{R}).

  6. R runs for 2 units (1818 to 2020), terminates. Ready queue: [Q][\text{Q}]. Switch: R→Q\text{R} \to \text{Q} (1st R→Q\text{R} \to \text{Q}).

  7. Q runs for 2 units (2020 to 2222), terminates.

  • Sequence of context switches: P→Q→R→S→Q→R→Q\text{P}\to\text{Q}\to\text{R}\to\text{S}\to\text{Q}\to\text{R}\to\text{Q}.

  • Exactly one S→Q\text{S} \to \text{Q}, exactly one R→Q\text{R} \to \text{Q}, exactly two Q→R\text{Q} \to \text{R}, zero S→P\text{S} \to \text{P}. This is possible.

Testing Option (B): P=2,Q=9,R=5,S=1\text{P}=2, \text{Q}=9, \text{R}=5, \text{S}=1

  • Execution order: P(2)→Q(4)→R(4)→S(1)→Q(4)→R(1)→Q(1)\text{P}(2) \to \text{Q}(4) \to \text{R}(4) \to \text{S}(1) \to \text{Q}(4) \to \text{R}(1) \to \text{Q}(1).

  • Switches: P→Q→R→S→Q→R→Q\text{P}\to\text{Q}\to\text{R}\to\text{S}\to\text{Q}\to\text{R}\to\text{Q}. Conditions satisfied.

Testing Option (C): P=4,Q=12,R=5,S=4\text{P}=4, \text{Q}=12, \text{R}=5, \text{S}=4

  • Execution order: P(4)→Q(4)→R(4)→S(4)→Q(4)→R(1)→Q(4)\text{P}(4) \to \text{Q}(4) \to \text{R}(4) \to \text{S}(4) \to \text{Q}(4) \to \text{R}(1) \to \text{Q}(4).

  • Switches: P→Q→R→S→Q→R→Q\text{P}\to\text{Q}\to\text{R}\to\text{S}\to\text{Q}\to\text{R}\to\text{Q}. Conditions satisfied.

Testing Option (D): P=3,Q=7,R=7,S=3\text{P}=3, \text{Q}=7, \text{R}=7, \text{S}=3

  1. P runs for 3 units (00 to 33), terminates. Ready queue: [Q,R,S][\text{Q}, \text{R}, \text{S}]. Switch: P→Q\text{P} \to \text{Q}.

  2. Q runs for 4 units (33 to 77), rem Q=3\text{Q}=3. Ready queue: [R,S,Q][\text{R}, \text{S}, \text{Q}]. Switch: Q→R\text{Q} \to \text{R} (1st Q→R\text{Q} \to \text{R}).

  3. R runs for 4 units (77 to 1111), rem R=3\text{R}=3. Ready queue: [S,Q,R][\text{S}, \text{Q}, \text{R}]. Switch: R→S\text{R} \to \text{S}.

  4. S runs for 3 units (1111 to 1414), terminates. Ready queue: [Q,R][\text{Q}, \text{R}]. Switch: S→Q\text{S} \to \text{Q} (1st S→Q\text{S} \to \text{Q}).

  5. Q runs for 3 units (1414 to 1717), terminates. Ready queue: [R][\text{R}]. Switch: Q→R\text{Q} \to \text{R} (2nd Q→R\text{Q} \to \text{R}).

  6. R runs for 3 units (1717 to 2020), terminates.

  • Sequence of context switches: P→Q→R→S→Q→R\text{P}\to\text{Q}\to\text{R}\to\text{S}\to\text{Q}\to\text{R}.

  • Here, the context switch from R to Q is 0 (after R finishes at the end, CPU goes idle, no switch to Q). Thus, condition "exactly one context switch from R to Q" is violated.

Therefore, option D is NOT possible.

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This CPU and I/O Scheduling previous year question is Q42 of the GATE CSE 2022 paper. Find more GATE CSE PYQs on CPU and I/O Scheduling in Operating Systems, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related CPU and I/O Scheduling PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

CPU and I/O Scheduling in GATE CSE

CPU and I/O Scheduling has 25 GATE CSE PYQs across 22 papers from 2011 to 2026. 7 of them are 2-mark MCQs like this one, and it is the only one in GATE CSE 2022.

How GATE tests CPU and I/O Scheduling

More from GATE CSE 2022

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2022 · Q42 · MCQ

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?

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.