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

Leave a Reply

Your email address will not be published. Required fields are marked *

555 Views
%d bloggers like this: