Shortest Job First (SJF) scheduling

In this topic, you will learn about, Shortest Job First (SJF) scheduling.

A different approach to CPU scheduling is the SJF algorithm. These algorithm associates with each process the length of the latter’s next CPU burst. When the CPU is in, it is assigned to that process that has the smallest next CPU burst. Therefore, this algorithm is also known as the Shortest Next CPU Burst algorithm.

This Shortest Next CPU Burst algorithm can be illustrated by the following examples: Process            Burst time
P1                       6
P2                       8
P3                       7
P4                       3

Shortest Next CPU Burst algorithm
                                                             Shortest Next CPU Burst algorithm

Average Turnaround Time= (3+9+16+24)/4 = 52/4   = 13
Average Waiting Time= (0+3+9+16)/4         =28/4    = 7

The SJF algorithm is provably optimal, in that it gives the minimum average waiting for a given set of processes. By moving a short process before a long one the waiting time of the short process decreases more than it increases the waiting time of the long process consequently, the average waiting time decreases.

The real difficulty with the short job first algorithm is knowing the length of the CPU request. SJF scheduling is used frequently in long term schedule. Although the SJF algorithm is optimal, it cannot be implemented at a level of short-term scheduling.

The SJF algorithm may be either primitive or non-primitive. Primitive SJF scheduling is sometimes called Shortest-Remaining-Time-First (SRTF) Scheduling.

See also  Process In Operating System

Comment below if you have queries related to the above topic, Shortest Job First (SJF) scheduling.