Scheduling algorithms hierarchy
A map of all algorithms by preemption and goal.
CPU Scheduling Algorithms Hierarchy
Interactive tree map—click any node to expand details or reveal sub-categories
-
CPU Scheduling Algorithms
Definition: The mechanism by which the Operating System's Short-Term Scheduler assigns processes from the Ready Queue to run on available CPU cores.
Primary Goal: Maximize CPU utilization & throughput while minimizing turnaround, waiting, and response times.
-
1. Non-Preemptive Scheduling Paradigm Cooperative
Core Rule: Once a process is allocated the CPU, it holds it until it voluntary yields control (e.g., requests I/O wait) or terminates.
- Pros: Low overhead (no context switches during execution), immune to race conditions on shared data.
- Cons: Poor interactive responsiveness; susceptible to process monopolization ("Convoy Effect").
-
First-Come, First-Served (FCFS)
Mechanism: Processes are dispatched strictly in order of their arrival time in the Ready Queue (FIFO structure).
Queue Logic: Standard FIFO Queue- Convoy Effect: If a long CPU-bound process arrives first, all short I/O-bound processes get stuck waiting behind it, severely tanking system utilization.
- Metrics: High average waiting time. Non-preemptive by definition.
-
Shortest Job First (SJF) [Non-Preemptive]
Mechanism: Associates each process with the length of its next CPU burst. The process with the smallest CPU burst time is allocated the CPU next.
Provably Optimal: Yields the absolute minimum average waiting time.- Burst Prediction: CPU burst length cannot be known in advance; it must be estimated using exponential smoothing:
τn+1 = α · tn + (1 - α) · τn - Starvation: Long CPU bursts may suffer infinite starvation if short processes continually arrive.
- Burst Prediction: CPU burst length cannot be known in advance; it must be estimated using exponential smoothing:
-
Priority Scheduling (Non-Preemptive)
Mechanism: Each process is assigned an integer priority rank. The CPU is allocated to the process with the highest priority (e.g., 0 = highest priority).
- Tie-Breaking: FCFS is typically used to resolve equal priority ties.
- Starvation & Aging: Low-priority processes can block indefinitely. Resolved using Aging (gradually increasing the priority of processes that wait in the queue for a long time).
-
Highest Response Ratio Next (HRRN)
Mechanism: A non-preemptive heuristic designed to eliminate SJF starvation while favoring shorter jobs.
Response Ratio (R) = (Waiting Time + Service Time) / Service Time- Shorter jobs get higher ratios due to smaller denominators.
- Longer jobs gain higher ratios automatically over time due to accumulating Waiting Time in the numerator.
-
2. Preemptive Scheduling Paradigm Interrupter
Core Rule: The OS can forcibly interrupt a currently executing process to reclaim the CPU for another process (triggered by timer interrupts or higher-priority arrivals).
- Pros: High interactive responsiveness, prevents CPU monopolization. Essential for time-sharing systems.
- Cons: Context switch overhead; requires synchronization mechanisms to prevent race conditions on shared kernel data structures.
-
Shortest Remaining Time First (SRTF)
Mechanism: The preemptive version of SJF. If a new process arrives in the Ready Queue with a remaining CPU burst time less than the currently running process's remaining time, the running process is preempted.
- Responsiveness: Offers better average response time than non-preemptive SJF for interactive environments.
- Drawback: High context switch count; requires continuous remaining burst estimation.
-
Round Robin (RR) Scheduling
Mechanism: Designed specifically for time-sharing. CPU time is partitioned into fixed time units called a Time Quantum (q) (typically 10–100 ms). The ready queue is treated as a circular FIFO queue.
Quantum Size Rule: q should be large relative to Context Switch Time (~80% of CPU bursts < q)- If
qis extremely large → RR degrades to FCFS. - If
qis extremely small → Causes excessive context switching overhead ("processor sharing").
- If
-
Preemptive Priority Scheduling
Mechanism: When a process arrives at the Ready Queue, its priority is compared with the currently running process. If the arriving process has a higher priority, the running process is preempted immediately.
- Commonly used in real-time operating systems (RTOS).
- Requires strict synchronization for kernel data access.
-
3. Multi-Queue & Advanced Paradigms
Modern production OS (Linux, Windows, macOS) use multi-queue structures to categorize workloads (e.g., interactive UI vs. background batch jobs).
-
Multilevel Queue (MLQ) Scheduling
Mechanism: Partitions the ready queue into separate queues (e.g., System Processes, Interactive, Batch). Processes are permanently assigned to a queue based on their properties.
- Each queue has its own scheduling algorithm (e.g., RR for Interactive, FCFS for Batch).
- Scheduling between queues usually uses fixed-priority preemptive scheduling (causes starvation of lower queues).
-
Multilevel Feedback Queue (MLFQ)
Mechanism: Allows processes to move between queues based on their historical CPU burst behavior. This dynamically learns the nature of processes without needing prior execution knowledge.
Rule: Short CPU bursts stay in top high-priority queues; CPU-bound jobs drop to lower queues.- Prevents starvation via periodic priority boosting across all queues.
- Represents the most general CPU scheduling framework used in commercial operating systems.
-
-