CREATE OWN LIBRARY

Shortest Job First (SJF) / Shortest Request Next (SRN) Scheduling

 

SJF process and examples:

This algorithm associate with each process the length of the process's next CPU burst. When the CPU is available, it is assigned to the process that has the smallest next CPU burst. Thus, a request remains pending until all shorter requests have been serviced. If the next CPU bursts of two processes are the same, FCFS scheduling is used to break the tie.

 

Criteria - Burst time

Mode - Non-preemptive

Data-structure - Min Heap is the efficient data structure of SJF.

 

Example:

 

 

Gantt chart:

 

 

TAT = CT - AT and WT = TAT - BT

 

 

SJF also suffers from the convoy effect i.e. if the larger process comes earlier then average waiting time will be increased.

 

Example 1: (Convoy effect)

 

 

 

Example 2: (No convoy effect)

 

 

 In this example waiting time is 0 for all processes.

 

# The SJF scheduling algorithm is probably optimal, it gives a minimum average waiting time for a given set of processes.

 

# Overall throughput of every scheduling algorithm is same but at any point time if we stop and calculate then SJF is the best (gives maximum throughput). 

 

# Practical implementation of SJF is not possible because burst time(Service time)of processes are not known to the operating system a priori, hence for OS, it is practically not possible to assign the shortest process to CPU from a set of processes in the ready queue.

 

# SJF Scheduling is used frequently in long-term scheduling. For long-term scheduling in a batch system, we can use the process time limit that a user specifies when he submits the job.