A computer has two processors, ๐1 and ๐2. Four processes ๐1, ๐2, ๐3, ๐4โฆ
2025
A computer has two processors, ๐1 and ๐2. Four processes ๐1, ๐2, ๐3, ๐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:
โข ๐1 uses priority of execution for the processes as, ๐1 > ๐3 > ๐2 > ๐4, i.e., ๐1 and ๐4 have highest and lowest priorities, respectively.ย
โข ๐2 uses priority of execution for the processes as, ๐2 > ๐3 > ๐4 > ๐1, i.e., ๐2 and ๐1 have highest and lowest priorities, respectively.ย
A process ๐๐ is scheduled to a processor ๐๐, if the processor is free and no other process ๐๐ 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
- A.
9.00
- B.
8.75
- C.
6.50
- D.
7.50
Attempted by 166 students.
Show answer & explanation
Correct answer: A
Given:
Bursts: P1 = 20 ms, P2 = 16 ms, P3 = 25 ms, P4 = 10 ms (all arrive at time 0)
Two processors, non-preemptive scheduling
Priorities on M1: P1 > P3 > P2 > P4
Priorities on M2: P2 > P3 > P4 > P1
Rule: When a processor becomes free, assign any waiting process provided there is no other waiting process with higher priority for that processor.
Step-by-step scheduling:
t = 0 (both processors free):
M1 runs P1 from 0 to 20 ms (P1 has highest priority on M1).
M2 runs P2 from 0 to 16 ms (P2 has highest priority on M2).
t = 16 ms (M2 becomes free; P1 still on M1):
Waiting processes: P3 and P4. For M2, P3 has higher priority than P4, so M2 runs P3 from 16 to 41 ms.
t = 20 ms (M1 becomes free; P3 running on M2):
Only P4 is waiting, and no higher-priority waiting process exists for M1, so M1 runs P4 from 20 to 30 ms.
Gantt-like view (times in ms):
M1: | P1 (0โ20) | P4 (20โ30) | idle (30โ41)
M2: | P2 (0โ16) | P3 (16โ41)
Waiting times (start time โ arrival time, arrival = 0):
P1: 0 ms
P2: 0 ms
P3: 16 ms
P4: 20 ms
Average waiting time = (0 + 0 + 16 + 20) / 4 = 9 ms
A video solution is available for this question โ log in and enroll to watch it.