SJF Full Form

SJF stands for Shortest Job First. It is a type of CPU scheduling. This algorithm associate with each process the length of the latter’s next CPU burst. When the CPU is available, it is assigned to the process that has the smallest next CPU burst time. It is a scheduling policy that selects for executing the waiting process with the smallest execution time. If two processes have the same length next CPU burst, First Come will be executed.

SJF-Full-Form

Characteristics

  • The SJF algorithm may be either preemptive or non-preemptive.
  • Shortest remaining time Scheduling is a preemptive variant of SJF scheduling.
  • This algorithm method is helpful for batch-type processing.
  • SJF scheduling is used frequently in long-term scheduling.

Example:
Process-Burst-SJF

Here, we are given 4 processes P1, P2, P3, and P4 and their burst time is 6, 8, 7, 3 respectively.
Let us assume they all arrive at the same time.
By definition of SJF scheduling, we can say that P4 will execute first, then P1, then P3, and at last P2 will execute.

Gantt chart will be:-
Gantt-Chart-SJF

The waiting time is 3 unit time for process P1, 16 unit time for process P2, 9 unit time for process P3, and 0 unit time for process P4.
Hence average waiting time is (3 + 16 + 9 + 0)/4 = 7 unit time.

Advantages

  • It reduces the average waiting time.
  • SJF scheduling gives the lowest average waiting time for a specific set of processes.
  • Probably optimal with regard to average turnaround time.

Disadvantages

  • It cannot be implemented at the level of short-term CPU scheduling.
  • It can leads to starvation of other processes if burst time of running process is very large.
  • Total execution time of a job must be known before execution.
  • There is no way to know the length of the next CPU burst.
My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

1


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.