Here are 30 questions on PS(Priority Scheduling) process scheduling algorithms (premptive AND non-premptive). Each question is presented in a table format, followed by the solution with Gantt charts, average turnaround time (TAT), and average waiting time (WT).
Question 11: Preemptive Priority Scheduling
find the average Turn Around Time and Waiting Time of following processes using Preemptive PS(Priority Scheduling) process scheduling algorithm?
Process | Arrival Time | Burst Time | Priority |
---|---|---|---|
P1 | 0 | 5 | 3 |
P2 | 1 | 3 | 1 |
P3 | 2 | 4 | 4 |
P4 | 3 | 2 | 2 |
P5 | 4 | 6 | 5 |
Solution :
lower number represents higher priority (here i take 1 as a highest priority)
Formula:
- Turnaround Time = Completion Time - Arrival Time
- Waiting Time = Turnaround Time - Burst Time
- Average Turnaround Time = Sum of Turnaround Times / Number of Processes
- Average Waiting Time = Sum of Waiting Times / Number of Processes
Gantt Chart
| P1 (0-1) | P2 (1-4) | P4 (4-6) | P1 (6-8) | P3 (8-12) | P5 (12-18) |
Process | Completion Time | Turnaround Time (TAT) | Waiting Time (WT) |
---|---|---|---|
P1 | 8 | 8 - 0 = 8 | 8 - 5 = 3 |
P2 | 4 | 4 - 1 = 3 | 3 - 3 = 0 |
P3 | 12 | 12 - 2 = 10 | 10 - 4 = 6 |
P4 | 6 | 6 - 3 = 3 | 3 - 2 = 1 |
P5 | 18 | 18 - 4 = 14 | 14 - 6 = 8 |
Average Turnaround Time:
(8 + 3 + 10 + 3 + 14) / 5 = 7.6 units
Average Waiting Time:
(3 + 0 + 6 + 1 + 8) / 5 = 3.6 units
Gantt Chart
| P1 (0-1) | P2 (1-4) | P4 (4-6) | P1 (6-8) | P3 (8-12) | P5 (12-18) |
Question 12: Non-Preemptive Priority Scheduling
find the average Turn Around Time and Waiting Time of following processes using Non-Preemptive PS(Priority Scheduling) process scheduling algorithm?
Process | Arrival Time | Burst Time | Priority |
---|---|---|---|
P1 | 1 | 3 | 2 |
P2 | 2 | 4 | 1 |
P3 | 3 | 6 | 4 |
P4 | 4 | 2 | 3 |
P5 | 5 | 5 | 5 |
P6 | 6 | 1 | 6 |
Solution :
lower number represents higher priority (here i take 1 as a highest priority)
Formula:
- Turnaround Time = Completion Time - Arrival Time
- Waiting Time = Turnaround Time - Burst Time
- Average Turnaround Time = Sum of Turnaround Times / Number of Processes
- Average Waiting Time = Sum of Waiting Times / Number of Processes
Gantt Chart
| P1 (1-4) | P2 (4-8) | P3 (8-14) | P4 (14-16) | P5 (16-21) | P6 (21-22) |
Process | Completion Time | Turnaround Time (TAT) | Waiting Time (WT) |
---|---|---|---|
P1 | 4 | 4 - 1 = 3 | 3 - 3 = 0 |
P2 | 8 | 8 - 2 = 6 | 6 - 4 = 2 |
P3 | 14 | 14 - 3 = 11 | 11 - 6 = 5 |
P4 | 16 | 16 - 4 = 12 | 12 - 2 = 10 |
P5 | 21 | 21 - 5 = 16 | 16 - 5 = 11 |
P6 | 22 | 22 - 6 = 16 | 16 - 1 = 15 |
Average Turnaround Time :
(3 + 6 + 11 + 12 + 16 + 16) / 6 = 10.67 units
Average Waiting Time:
(0 + 2 + 5 + 10 + 11 + 15) / 6 = 7.17 units
Gantt Chart
| P1 (1-4) | P2 (4-8) | P3 (8-14) | P4 (14-16) | P5 (16-21) | P6 (21-22) |