Difference between SJF and SRJF CPU scheduling algorithms

1. Shortest Job First (SJF) :
The Shortest Job First (SJF) is a scheduling policy that selects the waiting process with the smallest execution time to execute next. It is also known as Shortest Job Next (SJN) or Shortest Process Next (SPN). It a preemptive scheduling algorithm.

2. Shortest Remaining Job First (SRTF) :
The Shortest Remaining Job First (SRJF) is the preemptive version of SJF scheduling. In this scheduling algorithm, the process with the smallest amount of time remaining until completion is selected to execute. Processes having same arrival time will convert SRTF to SJF.

Similarities:

  • Both SJF and SRJF are practically not feasible as it is not possible to predict the burst time of the processes.
  • Both SJF and SRJF may lead to process starvation as long processes may be held off indefinitely if short processes are continually added.
  • Both SJF and SRJF are considered same once all the processes are available in the ready queue. This is because after the processes are added in the ready queue, no preemption is carried out.

Differences:



Shortest Job First: Shortest Remaining Job First:
It is a non-preemptive algorithm. It is a preemptive algorithm.
It involves less overheads than SRJF. It involves more overheads than SJF.
It is slower in execution than SRJF. It is faster in execution than SJF.
It leads to comparatively lower throughput. It leads to increased throughput as execution time is less.
It minimizes the average waiting time for each process. It may or may not minimize the average waiting time for each process.
It may suffer from priority inversion. It may suffer from convoy effect.
It involves lesser number of context switching. It involves higher number of context switching.
Short processes are executed first and then followed by longer processes. Shorter processes run fast and longer processes show poor response time.

Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.

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.