Skip to main content

Shortest job First (SJF)

  

Out of all available (waiting) processes, it selects the processes, it selects the process with the smallest burst time to execute next.

  • This algorithm for both Non-preemptive and Preemptive (SRTF- Shortest Remaining Time First).
  • If two processors the burst time is same then we will go with the first come first serve.
  • Here Completion time= Gantt chart values.
  •   Turn Around time = Completion time -  Arrival time.
  •  Waiting Time = Turn Around time -  Burst time.
  • Response time = Gantt chart values arrival - Arrival time.
  • It is preemption running process here in Gantt chart we check for processor for each and every one unit.
  • After all the elements in the ready queue it will work  as Non- Preemption.

Advantage of Shortest job First

  • Min average waiting time & min average Turn Around time.
  • Better Response time than FCFS.
  • Max Throughput.
  • Provides a standard for other algorithms in case of average waiting time.

Disadvantage

  • Can not be implemented.
  • Starvation problem with process having larger Burst time.

Shortest job First (SJF) with prediction of Burst Time in OS

  • Process Size.
  • Process type.
  • Simple Averaging (τ(n+1) = (1/n) ∑ T(i) )
  • Exponential average (Aging) – Τn+1 = αtn + (1 - α)Τn 
                         α = smoothing factor  and 0 <= α <= 1
                         tn = actual burst time of nth process
                          Τn = predicted burst time of nth process.