Shortest Job First Scheduling SJF Process Scheduling in operating systems

Shortest Job First Scheduling (SJF)

Process with less burst time will always execute first.

This is a non-preemptive scheduling algorithm so processes priority does not matter.

This is a pre-emptive scheduling algorithm.

Preferred to minimize waiting time.

Better than First come first served scheduling.

Works only when processor know in advance that how much time every process will take to execute on CPU.

Not preferred for interactive systems because required CPU time is not already in knowledge.[quads id=1]

Easy to implement in Batch systems because in batch systems CPU time is already known. 

Process Burst Time Arrival
P1 4 2nd
P2 2 3rd
P3 8 1st
P4 3 4th

 

P2 P4 P1 P3
0              2                5                 9         17

 

Process Waiting Time
P1 5
P2 0
P3 9
P4 2

Average Wait Time: (0+2+5+9) / 4 = 4

How to calculate turn around time?

TurnAroundTime=BurstTime+WaitingTime.

Program of Shortest Job First Scheduling (SJF) in C Language