Scheduling based on shortest CPU burst time
Shortest-Job-First (SJF) is a CPU scheduling algorithm that selects the process with the smallest CPU burst time from the ready queue. SJF can be implemented as either non-preemptive (once a process starts, it runs to completion) or preemptive (a new shorter process can interrupt a currently running process, known as Shortest-Remaining-Time-First). SJF is theoretically optimal for minimizing average waiting time, as shorter processes are given priority, reducing the waiting time of subsequent processes. However, SJF has several practical limitations: it requires accurate knowledge of CPU burst times which is often unavailable; it can lead to starvation of longer processes if short processes keep arriving; and it may not be suitable for interactive systems where response time is important. The preemptive version (SRTF) provides better response times but increases context switching overhead. SJF works well in batch systems where job characteristics are known in advance. Implementation typically requires maintaining the ready queue as a priority queue ordered by burst time. Despite its optimality for average waiting time, SJF is rarely used in pure form in modern systems due to its impracticality but influences the design of more adaptive scheduling algorithms.