PS(Priority Scheduling) premptive and non-premptive question

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 1 : 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 0 8 2
P2 1 4 1
P3 2 9 3
P4 3 5 4

Solution :

lower number represents higher priority (here i take 1 as a highest priority)

Formula:

Gantt Chart

| P1 (0-8) | P2 (8-12) | P3 (12-21) | P4 (21-26) |

Process Completion Time Turnaround Time Waiting Time
P1 8 8 0
P2 12 11 7
P3 21 19 10
P4 26 23 18

Average Turnaround Time: (8+11+19+23)/4 = 15.25

Average Waiting Time: (0+7+10+18)/4 = 8.75

Question 2 : 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 6 1
P2 2 2 3
P3 4 8 2
P4 6 4 4

Solution :

lower number represents higher priority (here i take 1 as a highest priority)

Formula:

Gantt Chart

| P1 (0-6) | P3 (6-14) | P2 (14-16) | P4 (16-20) |

Process Completion Time Turnaround Time Waiting Time
P1 6 6 0
P2 16 14 12
P3 14 10 2
P4 20 14 10

Average Turnaround Time: (6+14+10+14)/4 = 11

Average Waiting Time: (0+12+2+10)/4 = 6

Question 3 :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 0 5 3
P2 1 3 1
P3 2 4 2
P4 3 6 4

Solution :

lower number represents higher priority (here i take 1 as a highest priority)

Formula:

Gantt Chart

| P1 (0-5) | P2 (5-8) | P3 (8-12) | P4 (12-18) |

Process Completion Time Turnaround Time Waiting Time
P1 5 5 0
P2 8 7 4
P3 12 10 6
P4 18 15 9

Average Turnaround Time: (5+7+10+15)/4 = 9.25

Average Waiting Time: (0+4+6+9)/4 = 4.75

Question 4 : 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 7 2
P2 1 4 1
P3 2 6 3
P4 3 3 4

Solution :

lower number represents higher priority (here i take 1 as a highest priority)

Formula:

Gantt Chart

| P1 (0-1) | P2 (1-5) | P1 (5-11) | P3 (11-17) | P4 (17-20) |

Process Completion Time Turnaround Time Waiting Time
P1 11 11 4
P2 5 4 0
P3 17 15 9
P4 20 17 14

Average Turnaround Time: (11+4+15+17)/4 = 11.75

Average Waiting Time: (4+0+9+14)/4 = 6.75

Question 5 : 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? Consider the following processes with their Arrival Time, Burst Time, and Priority:

Process Arrival Time Burst Time Priority
P1 0 3 2
P2 2 5 1
P3 4 8 3
P4 6 6 4

Solution :

Formula:

Gantt Chart

| P1 (0-3) | P2 (3-8) | P3 (8-16) | P4 (16-22) |

Process Completion Time Turnaround Time Waiting Time
P1 3 3 0
P2 8 6 1
P3 16 12 4
P4 22 16 10

Average Turnaround Time: (3+6+12+16)/4 = 9.25

Average Waiting Time: (0+1+4+10)/4 = 3.75

Question 6: 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? Consider the following processes with their Arrival Time, Burst Time, and Priority:

Process Arrival Time Burst Time Priority
P1 0 5 2
P2 2 3 1
P3 4 1 4
P4 6 2 3

Solution :

lower number represents higher priority (here i take 1 as a highest priority)

Formula:

Gantt Chart

| P1 (0-5) | P2 (5-8) | P4 (8-10) | P3 (10-11) |

Process Arrival Time Burst Time Priority Completion Time Turnaround Time (TAT) Waiting Time (WT)
P1 0 5 2 5 5 - 0 = 5 5 - 5 = 0
P2 2 3 1 8 8 - 2 = 6 6 - 3 = 3
P3 4 1 4 11 11 - 4 = 7 7 - 1 = 6
P4 6 2 3 10 10 - 6 = 4 4 - 2 = 2
Average Turnaround Time:

(5 + 6 + 7 + 4) / 4 = 5.5 units

Average Waiting Time:

(0 + 3 + 6 + 2) / 4 = 2.75 units

Question 7 : Preemptive Priority Scheduling

find the average Turn Around Time and Waiting Time of following processes using Non-Preemptive PS(Priority Scheduling) process scheduling algorithm? Consider the following processes with their Arrival Time, Burst Time, and Priority:

Process Arrival Time Burst Time Priority
P1 0 7 1
P2 2 4 2
P3 4 1 3
P4 5 3 1
P5 6 2 4

Solution :

lower number represents higher priority (here i take 1 as a highest priority)

Formula:

Gantt Chart

| P1 (0-7) | P4 (7-10) | P2 (10-14) | P3 (14-15) | P5 (15-17) |

Process Arrival Time Burst Time Priority Completion Time Turnaround Time (TAT) Waiting Time (WT)
P1 0 7 1 7 7 - 0 = 7 7 - 7 = 0
P2 2 4 2 14 14 - 2 = 12 12 - 4 = 8
P3 4 1 3 15 15 - 4 = 11 11 - 1 = 10
P4 5 3 1 10 10 - 5 = 5 5 - 3 = 2
P5 6 2 4 17 17 - 6 = 11 11 - 2 = 09
Average Turnaround Time:

(7+12+11+5+11) / 5 = 9.2 units

Average Waiting Time:

(0+8+10+2+9) / 5 = 5.8 units

Question 8: 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? Consider the following processes with their Arrival Time, Burst Time, and Priority:

Process Arrival Time Burst Time Priority
P1 1 3 3
P2 2 6 2
P3 3 4 1
P4 5 5 4

Solution :

lower number represents higher priority (here i take 1 as a highest priority)

Formula:

Gantt Chart

| P1 (1-4) | P3 (4-8) | P2 (8-14) | P4 (14-19) |

Process Arrival Time Burst Time Priority Completion Time Turnaround Time (TAT) Waiting Time (WT)
P1 1 3 3 4 4 - 1 = 3 3 - 3 = 0
P2 2 6 2 14 14 - 2 = 12 12 - 6 = 6
P3 3 4 1 8 8 - 3 = 5 5 - 4 = 1
P4 5 5 4 19 19 - 5 = 14 14 - 5 = 9
Average Turnaround Time:

(3 + 12 + 5 + 14) / 4 = 8.5 units

Average Waiting Time:

(0 + 6 + 1 + 9) / 4 = 4 units

Question 9: Preemptive Priority Scheduling

find the average Turn Around Time and Waiting Time of following processes using Preemptive PS(Priority Scheduling) process scheduling algorithm? Consider the following processes with their Arrival Time, Burst Time, and Priority:

Process Arrival Time Burst Time Priority
P1 0 8 1
P2 1 4 3
P3 2 9 2
P4 3 5 4
P5 4 6 5

Solution :

lower number represents higher priority (here i take 1 as a highest priority)

Formula:

Gantt Chart

| P1 (0-8) | P3 (8-17) | P2 (17-21) | P4 (21-26) | P5 (26-32) |

Process Arrival Time Burst Time Priority Completion Time Turnaround Time (TAT) Waiting Time (WT)
P1 0 8 1 8 8 - 0 = 8 8 - 8 = 0
P2 1 4 3 21 21 - 1 = 20 20 - 4 = 16
P3 2 9 2 17 17 - 2 = 15 15 - 9 = 6
P4 3 5 4 26 26 - 3 = 23 23 - 5 = 18
P5 4 6 5 32 32 - 4 = 28 28 - 6 = 22
Average Turnaround Time:

(20 + 8 + 15 + 23 + 28) / 5 = 18.8 units

Average Waiting Time:

(0 + 16 + 6 + 18 + 22) / 5 = 12.4 units

Question 10: 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? Consider the following processes with their Arrival Time, Burst Time, and Priority:

Process Arrival Time Burst Time Priority
P1 1 5 2
P2 2 3 1
P3 3 6 4
P4 4 4 3
P5 5 2 5

Solution :

lower number represents higher priority (here i take 1 as a highest priority)

Formula:

Gantt Chart

| P1 (1-6) | P2 (6-9) | P4 (9-13) | P3 (139) | P5 (19-21) |

Process Arrival Time Burst Time Priority Completion Time Turnaround Time (TAT) Waiting Time (WT)
P1 1 5 2 6 6 - 1 = 5 5 - 5 = 0
P2 2 3 1 9 9 - 2 = 7 7 - 3 = 4
P3 3 6 4 19 19 - 3 = 16 16 - 6 = 10
P4 4 4 3 13 13 - 4 = 9 19 - 4 = 5
P5 5 2 5 21 21 - 5 = 16 16 - 2 = 14
Average Turnaround Time:

(5 + 7 + 16 + 9 + 16) / 5 = 10.6 units

Average Waiting Time:

(0 + 4 + 10 + 5+ 14) / 5 = 6.6 units