The following processes are being scheduled using a preemptive, priority-based, round-robin scheduling algorithm. Each process is assigned a numerical priority,with a higher number indicating a higher relative priority. The scheduler will execute the highest-priority process. For processes with the same priority, a round-robin scheduler will be used with a time quantum of 10 units. If a process is preempted by a higher-priority process, the preempted process is placed at the end of the queue.
Process Burst Time Arrival Time Priority
P1 15 0 8
P2 20 0 3
P3 20 20 4
P4 20 25 4
P5 5 45 5
P6 15 55 5
What is the average waiting time of these processes?
Solution
We know that:
Turnaround time(TAT) = Completion time(CT) - Arrival time(AT)
Waiting time(WT) = Turnaround time(TAT) - Burst time
The Gantt chart is shown below:
Process | Arrival Time | Burst Time | Completion Time | Turnaround Time | Waiting time |
P1 | 0 | 15 | 15 | 15 - 0 = 15 | 15 - 15 = 0 |
P2 | 0 | 20 | 95 | 95 - 0 = 95 | 95 - 20 =75 |
P3 | 20 | 20 | 55 | 55 - 20 = 35 | 35 - 20 = 15 |
P4 | 25 | 20 | 80 | 80 - 25 = 55 | 55 - 20 = 35 |
P5 | 45 | 5 | 50 | 50 - 45 = 5 | 5 - 5 = 0 |
P6 | 55 | 15 | 70 | 70 - 55 = 15 | 15 - 15 = 0 |
Average waiting time = (0 + 75 + 15 + 35 + 0 + 0)/6 = 125/6 = 20.833
Get Answers For Free
Most questions answered within 1 hours.