Skip to content
Official PYQ · 2025

GATE CS 2025 Set 1 Q28 — CPU Scheduling

Explain with AI

A computer has two processors, M1M_{1} and M2M_{2}. Four processes P1,P2,P3,P4P_{1}, P_{2}, P_{3}, P_{4} with CPU bursts of 20,16,2520,16,25, and 1010 milliseconds, respectively, arrive at the same time and these are the only processes in the system. The scheduler uses non-preemptive priority scheduling, with priorities decided as follows:

  • M1M_{1} uses priority of execution for the processes as, P1>P3>P2>P4P_{1}>P_{3}>P_{2}>P_{4}, i.e., P1P_{1} and P4P_{4} have highest and lowest priorities, respectively.
  • M2M_{2} uses priority of execution for the processes as, P2>P3>P4>P1P_{2}>P_{3}>P_{4}>P_{1}, i.e., P2P_{2} and P1P_{1} have highest and lowest priorities, respectively.

A process PiP_{i} is scheduled to a processor MkM_{k}, if the processor is free and no other process PjP_{j} is waiting with higher priority. At any given point of time, a process can be allocated to any one of the free processors without violating the execution priority rules. Ignore the context switch time. What will be the average waiting time of the processes in milliseconds?

Choose one option
View worked solution

Answer: A

We are given two processors, M1M_1 and M2M_2, and four processes P1,P2,P3,P4P_1, P_2, P_3, P_4 arriving at t=0t = 0 with CPU bursts of 20,16,25,20, 16, 25, and 1010 ms, respectively.

The priority orders on the processors are:

  • On M1M_1: P1>P3>P2>P4P_1 > P_3 > P_2 > P_4
  • On M2M_2: P2>P3>P4>P1P_2 > P_3 > P_4 > P_1

Let's trace the scheduling step-by-step:

  1. At t=0t = 0: Both M1M_1 and M2M_2 are free.
    • On M1M_1, the highest priority waiting process is P1P_1. Thus, P1P_1 is scheduled on M1M_1 (runs from t=0t = 0 to t=20t = 20).
    • On M2M_2, the highest priority waiting process is P2P_2. Thus, P2P_2 is scheduled on M2M_2 (runs from t=0t = 0 to t=16t = 16).
  2. At t=16t = 16: M2M_2 becomes free. The waiting processes are P3P_3 and P4P_4.
    • On M2M_2, the priority order is P3>P4P_3 > P_4. Thus, P3P_3 is scheduled on M2M_2 (runs from t=16t = 16 to t=41t = 41).
  3. At t=20t = 20: M1M_1 becomes free. Only P4P_4 is waiting.
    • P4P_4 is scheduled on M1M_1 (runs from t=20t = 20 to t=30t = 30).

Now, we calculate the waiting times for each process:

  • Waiting time of P1=0P_1 = 0 ms
  • Waiting time of P2=0P_2 = 0 ms
  • Waiting time of P3=16−0=16P_3 = 16 - 0 = 16 ms
  • Waiting time of P4=20−0=20P_4 = 20 - 0 = 20 ms

The average waiting time is:

Average Waiting Time=0+0+16+204=364=9.00 ms\text{Average Waiting Time} = \frac{0 + 0 + 16 + 20}{4} = \frac{36}{4} = 9.00 \text{ ms}

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore CPU Scheduling questions