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.
- 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.
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:-
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.
- 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.
- 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.
- Difference between SJF and LJF CPU scheduling algorithms
- Difference between SJF and SRJF CPU scheduling algorithms
- TCL Full Form
- LFU Full Form
- VPN Full Form
- DOS Full Form
- SAS Full Form
- OSI Model Full Form in Computer Networking
- HDMi Full Form
- LCD Full Form
- ZIP Full Form
- API Full Form
- RTC Full Form
- VLAN Full Form
- WPA Full Form
- DQL Full Form
- VGA Full Form
- SGML Full Form
- DHCP Full Form
- LED Full Form
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.