Difference between Shortest Job First (SJF) and Round-Robin (RR) scheduling algorithms
Last Updated :
26 Apr, 2025
The performance of the multiprocessor system and time-sharing system rely upon CPU scheduling algorithm. Some of the well known efficient CPU scheduling algorithms are Round Robin scheduling (RR), Shortest job first(SJF), Preemptive version of SJF(SRTF), First Come First Serve (FCFS) etc.
As of now, the Round Robin scheduling algorithm is considered as the efficient process scheduling algorithm among all the existing CPU scheduling algorithms. However, in RR the shortest one has to wait for a longer time and in SRTF longer process behaves as a suspended process as short tasks keep on executing.
Shortest Job First
Shortest Job First (SJF) Scheduling Algorithm is based on the burst time of the process. The processes are put into the ready queue based on their burst times.
In this algorithm, the process with the least burst time is processed first. The burst time of only those processes is compared that are present or have arrived until that time. It is also non-preemptive in nature. Its preemptive version is called Shortest Remaining Time First (SRTF) algorithm.
- The major advantage of this algorithm is that it gives the minimum waiting time for a given set of processes and thus reduces the average waiting time.
- The disadvantage of this algorithm is that long processes may never be processed by the system and may remain in the queue for very long time leading to starvation of processes.
Note : If two processes have same burst time then the tie is broken using FCFS, i.e., the process that arrived first is processed first.
Read more about Shortest Remaining Time First (SRTF) algorithm.
Round Robin
Round-Robin (RR) Scheduling Algorithm is particularly designed for time sharing systems. The processes are put into the ready queue which is a circular queue in this case. In this case, a small unit of time known as time quantum is defined.
- The algorithm selects the first process from the queue and executes it for the time defined by the time quantum. If the process has burst time less than the time quantum, then the CPU executes the next process but if it has burst time higher than the time quantum then the process is interrupted and next process is executed for same time quantum.
- If a process is interrupted, then a context switch happens and the process is put back at the tail of the queue. It is preemptive in nature. This algorithm mainly depends on the time quantum. Very large time quantum makes RR same as the FCFS while a very small time quantum will lead to the overhead as context switch will happen again and again after very small intervals.
- The major advantage of this algorithm is that all processes get executed one after the other which does not lead to starvation of processes or waiting by process for quite long time to get executed.
- A major disadvantage of Round Robin is its fixed time slice value.
Read more about Round-Robin (RR) Scheduling.
Difference between Shortest Job First (SJF) and Round-Robin (RR) scheduling algorithms
Feature | Shortest Job First (SJF) | Round-Robin (RR) |
---|
Scheduling Type | Non-preemptive (or preemptive as SRTF). | Preemptive. |
Execution Order | Based on burst time (shortest job first). | Based on time quantum (each process gets equal time slices). |
Average Waiting Time | Minimum for a given set of processes. | Depends on time quantum , generally low. |
Fairness | May lead to starvation of longer jobs. | Fair to all processes , avoids starvation. |
Implementation | Hard to predict exact CPU burst time. | Easy to implement. |
Overhead | Overhead from tracking burst times. | Overhead from frequent context switching if time quantum is too small. |
User Experience | May delay long processes. | Feels responsive , all users get regular CPU access. |
Best Used For | Batch systems where execution time is known. | Time-sharing systems (interactive systems). |
Key Points
- SJF is efficient in terms of average waiting time, but requires knowing the CPU burst time in advance, which is often not practical.
- RR is better for multi-user environments because it treats all tasks equally and provides better response time.
- SRTF (Shortest Remaining Time First) is the preemptive form of SJF.
- Too small a time quantum in RR leads to too many context switches, increasing system overhead.