Numerical Solved by Priority Scheduling

Q2. Consider the following set of processes with given priorities and burst time assumed to be arrived at 0.

Process                Priority                Burst Time

P1                           3                              6

P2                           2                              2

P3                           1                              14

P4                           4                              6

Draw Gantt Chart and calculate average turnaround and waiting time using Priority Scheduling Algorithm.

Ans. When priority scheduling is implemented the following sequence of processes would be generated:

Gantt Chart:

 P3 P2 P1 P4

0                                 14               16                                           24                                      32

P1’s waiting time=16

P2’s waiting time=14

P3’s waiting time=0

P4’s waiting time=24

Average Waiting Time

=(16+14+0+24)/4

=13.5 millisecond

Turnaround Time

Turnaround Time = Burst Time + Waiting Time

Process                     Turnaround Time

P1                               6+16=22

P2                               2+14=16

P3                               14+0=14

P4                               6+24=30

Average Turnaround Time

=(22+16+14+30)/4

=20.5 milliseconds

Numerical Solved by Round Robin Scheduling using Switching

Q5. Take three processes that arrive at the same time in the following order and the time quantum is 2ms.

Process                Burst Time

P1                          10

P2                          5

P3                          2

Draw Gantt Chart and calculate average turnaround time using Round Robin Scheduling Algorithm along with Switching.

Ans. Gantt Chart:

 P1 P2 P3 P1 P2 P1 P2 P1 P1

0      2       3       5     6        8      9     11      12    14    15     17    18     19    20     22   23  25

Turnaround Time

P1=25

P2=19

P3=18

Average Turnaround Time

=(25+19+18)/3

=52/3

=17.6 ms

Numerical Solved by Round Robin Scheduling without using Switching

Q4. Take three processes that arrive at the same time in the following order and the time quantum is 2ms.

Process                Burst Time

P1                           10

P2                           5

P3                           2

Draw Gantt Chart and calculate average turnaround and waiting time using Round Robin Scheduling Algorithm without Switching.

Ans.

Grant Chart:

 P1 P2 P3 P1 P2 P1 P2 P1 P1

0             2              4               6              8             10            12            13             15         17

Turnaround Time

Turnaround Time = Burst Time + Waiting Time

P1=17

P2=13

P3=6

Average Turnaround Time

=(17+13+6)/3

=36/3

=12 ms

Numerical Solved by Round Robin Scheduling Algorithm

Q3. Take three processes that arrive at the same time in the following order and the time quantum is 4ms.

Process                Burst Time

P1                           24

P2                           3

P3                           3

Draw Gantt Chart and calculate average turnaround and waiting time using Round Robin Scheduling Algorithm.

Ans.

Gantt Chart:

 P1 P2 P3 P1 P1 P1 P1

0                  4                   7                 10                 14                 18                 22              26

P1’s waiting time=6

P2’s waiting time=4

P3’s waiting time=7

Average Waiting Time

=(6+4+7)/3

=17/3

=5.6 ms

Turnaround Time

Turnaround Time = Burst Time +Waiting Time

P1=30-0=30

P2=7

P3=10

P1’s waiting time=9-1=8

P2’s waiting time=4-3=1

P3’s waiting time=6-2=4

P4’s waiting time=3-3=0

Average Turnaround Time

=(30+7+10)/3

=47/3

=15.6 ms

Numerical Solved by Round Robin

Q2. Take four processes that arrive at the same time in the following order and the time quantum is 20.

Process                         Burst Time

P1                                    53

P2                                    17

P3                                    68

P4                                    24

Draw Gantt Chart and calculate average turnaround and waiting time using Round Robin Scheduling Algorithm.

Ans.

Gantt Chart:

 P1 P2 P3 P4 P1 P3 P4 P1 P3 P3

0           20           37          57          77           97         117        121         134         154     162

Waiting Time

P1’s waiting time=57+24=81

P2’s waiting time=20

P3’s waiting time=37+40+17=94

P4’s waiting time=57+40=97

Average Waiting Time

=(81+20+94+97)/4

=73 milliseconds

Turnaround Time

Turnaround Time = Burst Time + Waiting Time

P1=53+81=134

P2=17+20=37

P3=68+9=162

P4=24+97=121

Average Turnaround Time

=(134+37+162+121)/4

=113.5 millisecond

Numerical Solved by Shortest Job First Scheduling Algorithm

Q8. Consider the following:

Arrive Time             Process                Burst Time

0                               P1                        10

1                               P2                        4

2                               P3                        3

3                               P4                        1

Draw Gantt Chart and calculate average turnaround and waiting time using Shortest Job First Scheduling Algorithm.

Grant Chart:

 P1 P2 P4 P2 P3 P1

0           1                     3           4                         6                               9                              18

Turnaround Time

P1=18-0=18

P2=6-1=5

P3=9-2=7

P4=4-3=1

Average Turnaround Time

=(18+5+7+1)/4

=31/4

=7.77 ms

Waiting Time

P1’s waiting time=9-1=8

P2’s waiting time=4-3=1

P3’s waiting time=6-2=4

P4’s waiting time=3-3=0

Average Waiting Time

=(8+1+4+0)/4

=13/4

=3.25 ms

Numerical Solved using Preemptive Shortest Job First Scheduling Algorithm

Q7. Consider the following Gantt Chart:

 P1 P2 P3 P2 P4 P1

0                2                 4            5                               7                                11                       16

Calculate Average Turnaround Time and Waiting Time by using Preemptive Shortest Job First Scheduling Algorithm.

Ans.

P1’s waiting time=9

P2’s waiting time=1

P3’s waiting time=0

P4’s waiting time=2

Average Waiting Time

=(9+1+0+2)/4

=3 ms

Turnaround Time

Turnaround Time = Burst Time + Waiting Time

Process                     Turnaround Time

P1                               7+9=16

P2                               4+1=5

P3                               1+0=1

P4                               4+2=6

Average Turnaround Time

=(16+5+1+6)/4

=28/4

=7 ms

Numerical Solved by FCFS

Q5. Consider the set of process P1,P2,P3,P4 and P5 having burst time as 10,1,2,1 and 5 ms and priority 5,1,3,4 and 2. The processes are assumed to have arrived at time 0, then draw Gantt Chart and calculate average turnaround and waiting time using First Come First Serve Scheduling Algorithm.

Ans. Solving by FCFS

Process                Burst Time           Priority Time

P1                        10                        5

P2                        1                           1

P3                        2                           3

P4                        1                           4

P5                        5                           2

Gantt Chart:

 P1 P2 P3 P4 P5

0                               10                             11                   13          14                                  19

P1’s waiting time=0

P2’s waiting time=10

P3’s waiting time=11

P4’s waiting time=13

P5’s waiting time=14

Waiting Time

=(0+10+11+13+14)/5

=48/5

=9.6 ms

Turnaround Time

P1=10

P2=11

P3=13

P4=14

P5=19

Average Turnaround Time

=(10+11+13+14+19)/5

=67/5

=13.6 MS

Numerical Solved by SJF

Q5. Consider the set of process P1,P2,P3,P4 and P5 having burst time as 10,1,2,1 and 5 ms and priority 5,1,3,4 and 2. The processes are assumed to have arrived at time 0, then draw Gantt Chart and calculate average turnaround and waiting time using Shortest Job First Scheduling Algorithm.

Ans. Solving by SJF

Process                Burst Time           Priority Time

P1                        10                        5

P2                        1                           1

P3                        2                           3

P4                        1                           4

P5                        5                           2

Gantt Chart

 P2 P4 P3 P5 P1

0               1               2                      4                            9                                                    19

Turnaround Time

P1=19

P2=1

P3=4

P4=2

P5=9

Average Turnaround Time

=(19+1+4+2+9)/5

=35/5

=7 milliseconds

Waiting Time

P1’s waiting time=9

P2’ waiting time=0

P3’s waiting time=2

P4’swaiting time=1

P5’s waiting time=4

Average Waiting Time

=(9+0+2+1+4)/5

=16/5

=3.2 ms