FCFS · SJF · Round Robin · Priority · Compare
SJF Scheduling Calculator
Non-preemptive CPU scheduling. Among arrived processes, the shortest burst runs next.
| PID | Arrival | Burst |
|---|
What is SJF Scheduling?
SJF (Shortest Job First) is a CPU scheduling algorithm that selects the process with the shortest CPU burst time among the processes that are ready to run.
Is SJF Preemptive or Non-Preemptive?
SJF (Shortest Job First) is a non-preemptive scheduling algorithm. Once a process starts running, it continues until it completes. The process with the shortest burst time is selected from the available processes.
A related algorithm called Shortest Remaining Time First (SRTF) is the preemptive version of SJF.
How SJF Works
When the CPU becomes available, SJF checks the processes that have already arrived and selects the process with the shortest burst time. In non-preemptive SJF, the selected process continues until it finishes.
SJF Scheduling Formulas
Turnaround Time = Completion Time − Arrival Time
Waiting Time = Turnaround Time − Burst Time
Advantages and Disadvantages of SJF
| Advantages of SJF | Disadvantages of SJF |
|---|---|
| Can produce a low average waiting time. | The exact burst time may not be known in advance. |
| Short processes can finish quickly. | Long processes may experience starvation. |
| Simple to understand for basic scheduling problems. | It can be difficult to use in some real-time systems. |
SJF Scheduling Example
Suppose several processes have arrived and the CPU becomes available. If P1 has a burst time of 8, P2 has a burst time of 3, and P3 has a burst time of 5, SJF selects the shortest available process first.
The scheduling order depends on both the arrival time and burst time of the processes.
SJF vs FCFS
FCFS schedules processes according to arrival order, while SJF selects the shortest available burst. SJF can achieve a lower average waiting time, but it requires information about process burst times.
Related CPU Scheduling Calculators
Try the FCFS Calculator, Round Robin Calculator, or Priority Scheduling Calculator .