/ˈskɛdʒʊlər/
noun — "decides which task runs when."
Scheduler is a core component of an operating system responsible for allocating CPU time and other resources among competing processes or threads. It determines the order and duration of execution, aiming to optimize system performance, responsiveness, fairness, or real-time constraints depending on the policy employed. The scheduler operates at multiple levels, including long-term, medium-term, and short-term scheduling, each focusing on different aspects of resource management.
Technically, a scheduler uses data structures such as queues, priority lists, and timing mechanisms to track ready and waiting tasks. Long-term scheduling controls the admission of new processes into the system, balancing workload and memory usage. Medium-term scheduling temporarily suspends and resumes processes to optimize CPU utilization and memory allocation. Short-term scheduling, or CPU scheduling, selects which ready process receives the CPU next, often using algorithms like First-Come-First-Served (FCFS), Shortest Job Next (SJN), Round-Robin (RR), or Least Recently Used-inspired variants for resource-sensitive contexts.
Schedulers may be preemptive or non-preemptive. In preemptive scheduling, a running process can be interrupted and replaced by a higher-priority task or based on a time slice expiration. Non-preemptive scheduling allows a process to run until it voluntarily yields or completes, reducing context switch overhead but potentially causing starvation. The operating system maintains a process control block (PCB) containing scheduling-related metadata such as priority, execution time, and state, which the scheduler references when making decisions.
Example conceptual flow of CPU scheduling:
while system has ready processes:
select process based on policy
allocate CPU for time slice
if process completes or yields:
update state
else if time slice expires:
preempt and requeue
Operationally, the scheduler affects throughput, latency, fairness, and responsiveness. In desktop environments, it ensures interactive applications respond promptly. In real-time systems, it enforces strict deadlines to prevent missed timing constraints. In multiprocessor or multicore systems, the scheduler also manages load balancing, affinity, and cache locality to maximize parallel efficiency.
Advanced schedulers incorporate heuristics, dynamic priority adjustments, and aging to prevent starvation and optimize for specific workloads. In virtualized environments, hypervisors implement additional scheduling layers to manage CPU allocation across multiple virtual machines.
Conceptually, the scheduler is like a traffic controller for the CPU, deciding which vehicle (process or thread) moves through the intersection at any moment to maintain order, efficiency, and fairness in a complex system.
See Process, Thread, CPU, Operating System, LRU.