Question

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, 25, and 10 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
Official answer and solution
Official answer
A
From
Official GATE 2025 answer key

Solution

Simulate the two-processor non-preemptive schedule starting from t=0t = 0 when all four processes arrive.

All four processes arrive at t=0t = 0 with bursts B(P1)=20B(P_1) = 20, B(P2)=16B(P_2) = 16, B(P3)=25B(P_3) = 25, B(P4)=10B(P_4) = 10:

  1. At t=0t = 0:
    • On M1M_1, P1P_1 has the highest priority, so P1P_1 is scheduled on M1M_1 for [0,20][0, 20]. Waiting time W(P1)=0 msW(P_1) = 0\text{ ms}.
    • On M2M_2, P2P_2 has the highest priority, so P2P_2 is scheduled on M2M_2 for [0,16][0, 16]. Waiting time W(P2)=0 msW(P_2) = 0\text{ ms}.
  2. At t=16t = 16:
    • M2M_2 finishes P2P_2 and becomes free. The waiting processes are {P3,P4}\{P_3, P_4\}.
    • On M2M_2, P3>P4P_3 > P_4, so P3P_3 is scheduled on M2M_2 for [16,41][16, 41]. Waiting time W(P3)=16 msW(P_3) = 16\text{ ms}.
  3. At t=20t = 20:
    • M1M_1 finishes P1P_1 and becomes free. The only waiting process is P4P_4.
    • P4P_4 is scheduled on M1M_1 for [20,30][20, 30]. Waiting time W(P4)=20 msW(P_4) = 20\text{ ms}.

Therefore, 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}
Final answer

Option (A)

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

Source

Paper
GATE 2025 Computer Science and Information Technology - Session 1 (CS1)
Question
38 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.