Complete Computer Knowledge Portal

Wednesday, April 24, 2013

Shortest Job First (SJF) CPU Scheduling

It is a CPU Scheduling Technique in which CPU is allocated to the process whose burst time is minimal.
Consider the following set of processes with the length of the CPU burst given in millisecond.
Process             Burst time
   P1                         10
   P2                          5
   P3                          1
   P4                          4



Using SJF Scheduling we Schedule these process according to Gantt chart as:







The waiting time for P3 is 0 for P4 it is 1, P2 is 5 and P1 is 10 Hence the average waiting time is (0+1+5+10/4)=4 milliseconds.
But if we calculate this by FCFS algorithm it comes: 0+10+15+16/4=10.25 milliseconds

Thus SJF gives optimal performance. It gives minimum average waiting for a set of processes.The main problem of this scheduling Technique is knowing the length of the next CPU request. This approach can not be used with short term scheduling because there is no way to know the length of next CPU burst time.

No comments:

Post a Comment