Question:

Given Data:
- Two processors: \( M_1 \) and \( M_2 \)
- Four processes: \( P_1, P_2, P_3, P_4 \)
- CPU bursts: \( P_1 = 20 \), \( P_2 = 16 \), \( P_3 = 25 \), \( P_4 = 10 \)
- Priority order for \( M_1 \): \( P_1 > P_3 > P_2 > P_4 \)
- Priority order for \( M_2 \): \( P_2 > P_3 > P_4 > P_1 \)
- Scheduling: Non-preemptive priority scheduling

Step 1: Assigning Processes to Processors
At \( t = 0 \), both processors are free. The highest-priority process for each processor is scheduled:
- \( M_1 \) gets \( P_1 \) (highest priority on \( M_1 \), burst = 20 ms).
- \( M_2 \) gets \( P_2 \) (highest priority on \( M_2 \), burst = 16 ms).

Step 2: Scheduling Remaining Processes
- \( P_2 \) finishes at \( t = 16 \), so \( M_2 \) picks the next highest-priority process, \( P_3 \) (burst = 25 ms).
- \( P_1 \) finishes at \( t = 20 \), so \( M_1 \) picks \( P_4 \) (burst = 10 ms).
- \( P_4 \) finishes at \( t = 30 \), and \( P_3 \) finishes at \( t = 41 \).

Step 3: Calculate Waiting Times
- \( P_1 \) starts at 0, so waiting time = \( 0 \) ms.
- \( P_2 \) starts at 0, so waiting time = \( 0 \) ms.
- \( P_3 \) starts at 16, so waiting time = \( 16 \) ms.
- \( P_4 \) starts at 20, so waiting time = \( 20 \) ms.

Step 4: Compute Average Waiting Time
\[ \text{Average waiting time} = \frac{(0 + 0 + 16 + 20)}{4} = \frac{36}{4} = 9 \text{ ms}. \]

Final Answer: The average waiting time of the processes is \( 9 \) milliseconds.

Show Hint

In priority scheduling, the waiting time depends on the order in which processes are executed. The waiting time for each process is the total time it waits for other higher-priority processes to finish.
Updated On: Apr 4, 2025
  • 9.00
  • 8.75
  • 6.50
  • 7.50
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is A

Solution and Explanation

Step 1: Initial Setup and Process Priorities
- Processor \( M_1 \) priority order: \( P_1 > P_3 > P_2 > P_4 \).
- Processor \( M_2 \) priority order: \( P_2 > P_3 > P_4 > P_1 \).
- CPU burst times:
\( P_1 = 20 \) ms, \( P_2 = 16 \) ms, \( P_3 = 25 \) ms, \( P_4 = 10 \) ms.

Step 2: Process Scheduling
- \( M_1 \) schedules \( P_1 \) first (highest priority), running for 20 ms.
- \( M_2 \) schedules \( P_2 \) first (highest priority), running for 16 ms.
- Remaining processes: \( P_3 \) (25 ms), \( P_4 \) (10 ms).
- \( M_1 \) next schedules \( P_3 \) (second priority), running for 25 ms.
- \( M_2 \) next schedules \( P_4 \) (second priority), running for 10 ms.

Step 3: Calculating Waiting Times
- \( P_1 \): Starts at \( t=0 \), waiting time = 0 ms.
- \( P_2 \): Starts at \( t=0 \), waiting time = 0 ms.
- \( P_3 \): Starts after \( P_2 \) finishes, at \( t=16 \), so waiting time = 16 ms.
- \( P_4 \): Starts after \( P_1 \) finishes, at \( t=20 \), so waiting time = 20 ms.

Step 4: Calculating Average Waiting Time
Total waiting time = \( 0 + 0 + 16 + 20 = 36 \) ms.
Average waiting time = \( \frac{36}{4} = 9 \) ms.

Final Answer: The average waiting time is 9 milliseconds.
Was this answer helpful?
0
0

Questions Asked in GATE CS exam

View More Questions