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 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

Shortest Job First

Q1. Explain Shortest Job First (SJF).

Q2. What is the classification of Shortest Job First Scheduling Algorithm?

Q3. Explain Non-preemptive Shortest Job First Scheduling with example.

Q4. Does arrival time of processes effect scheduling, if yes, than explain with example.

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 Algorithm.

Q6. Explain Preemptive Shortest Job First.

Q7. Consider the following Gantt Chart:

P1 P2 P3 P2 P4 P1

0                2                 4            5                               7                            11                       16

Calculate Turnaround Time and Waiting Time by using Preemptive 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.

Q9. What are the drawbacks of SJF?