Consider the following set of processes, assumed to have arrived at time 0 in the order P1, P2, P3, P4, and P5, with the given length of the CPU burst (in milliseconds) and their priority:
\[\begin{array}{|c|c|c|}\hline \text{Process} & \text{Burst Time (ms)} & \text{Priority} \\ \hline \text{P1} & 10 & 3 \\ \hline \text{P2} & 1 & 1 \\ \hline \text{P3} & 4 & 4 \\ \hline \text{P4} & 1 & 2 \\ \hline \text{P5} & 5 & 5 \\ \hline \end{array}\]
Using priority scheduling (where priority 1 denotes the highest priority and priority 5 denotes the lowest priority), find the average waiting time.
**Step 1: Determine the process execution order based on priority.**
We execute the processes in order of priority (highest to lowest):
- **P2** (Priority 1) runs first.
- **P4** (Priority 2) runs next.
- **P1** (Priority 3) runs after P4.
- **P3** (Priority 4) runs after P1.
- **P5** (Priority 5) runs last.
**Step 2: Calculate the waiting time.** The waiting time for each process is the total time the process spends waiting in the ready queue before it starts execution.
- **P2**: Waits 0 ms (it is the first to execute).
- **P4**: Waits for P2 to finish, which is 1 ms.
- **P1**: Waits for P2 and P4 to finish, which is 1 + 1 = 2 ms.
- **P3**: Waits for P2, P4, and P1 to finish, which is 1 + 1 + 10 = 12 ms.
- **P5**: Waits for P2, P4, P1, and P3 to finish, which is 1 + 1 + 10 + 4 = 16 ms.
**Step 3: Calculate the average waiting time.** The average waiting time is the sum of the waiting times divided by the number of processes:
\[ \text{Average waiting time} = \frac{0 + 1 + 2 + 12 + 16}{5} = \frac{31}{5} = 5.2 \text{ ms} \] Thus, the correct answer is **5.2 milliseconds**.