Process Scheduling
Process scheduling is how an operating system decides which of several ready processes gets the CPU next, and for how long. Because there are far fewer CPU cores than processes, the scheduler makes multitasking work by rapidly switching between processes according to a policy such as FCFS, SJF, Round Robin or priority scheduling.
Process scheduling is the part of the operating system responsible for deciding which process, among all the ones currently ready to run, actually gets the CPU next. Since a computer typically has far fewer CPU cores than processes wanting to run, the scheduler is what makes multitasking actually work, giving the impression that many programs run simultaneously by rapidly switching between them.
Why scheduling is needed at all
At any moment, a system might have dozens or hundreds of processes in a ready state, all wanting CPU time, but only a handful of CPU cores available. The scheduler's job is to pick, from all the ready processes, which one runs next, based on some policy (this is what the many specific scheduling algorithms, FCFS, SJF, Round Robin, Priority Scheduling, and others, each covered in their own topics, actually implement).
The three levels of scheduling
Operating systems textbooks typically describe scheduling at three levels, though general-purpose OSes mostly focus on the second:
Long-term scheduler. Decides which processes get admitted into the system (moved from disk into the ready queue) in the first place, controlling the overall degree of multiprogramming.
Short-term scheduler (the CPU scheduler). Decides which ready process actually runs next on the CPU. This runs extremely frequently, potentially thousands of times a second, and is what people usually mean by "the scheduler."
Medium-term scheduler. Handles swapping processes out of memory entirely (suspending them) and back in later, to manage overall system memory pressure.
What a scheduling decision actually involves
Every scheduling algorithm is really answering the same question differently: given the ready queue right now, which process should get the CPU, and should the currently-running process ever be interrupted before it naturally finishes or blocks (this is the preemptive vs non-preemptive distinction, covered in its own topic)? Different algorithms optimize for different goals: minimizing average waiting time, maximizing fairness, guaranteeing responsiveness for interactive use, or respecting explicit priority levels.
A concrete illustration
Say three processes are all sitting in the ready queue at the same moment: a background file-indexing job, an interactive text editor waiting for the CPU after the user just pressed a key, and a long-running video encode. A scheduler optimized purely for throughput might let the encode run uninterrupted for a long stretch, but a real desktop OS scheduler will instead prioritize the interactive text editor, since a noticeable delay in the editor responding to a keystroke is a far worse experience than the video encode finishing a few seconds later. This is exactly why real schedulers weigh interactivity and fairness, not just raw efficiency.
Where this matters in real systems
Linux's default scheduler, the Completely Fair Scheduler (CFS), is a real, production implementation of these tradeoffs: it tracks how much CPU time each process has received relative to its fair share and always favors whichever runnable process is furthest behind, balancing fairness against responsiveness for interactive workloads. Windows and macOS run conceptually similar multi-level, priority-aware schedulers under the hood.
What interviewers actually ask about process scheduling
- "What is the difference between the long-term and short-term scheduler?" The long-term scheduler decides which processes get admitted into the system at all; the short-term scheduler decides which already-ready process gets the CPU right now, and runs far more frequently.
- "What are the typical goals a scheduler tries to balance?" Minimizing waiting/turnaround time, maximizing CPU utilization and throughput, ensuring fairness, and providing good responsiveness for interactive processes.
- "Name a real scheduler used in a production operating system." Linux's Completely Fair Scheduler (CFS), which tracks each process's accumulated CPU time and favors whichever process has received the least relative to its fair share.
- "Why can't a scheduler optimize for every goal simultaneously?" Because the goals genuinely conflict, for example, maximizing raw throughput might mean letting long jobs run uninterrupted, while good interactive responsiveness requires frequently interrupting long jobs to service short, latency-sensitive ones.
Key takeaways
- Process scheduling decides which ready process gets the CPU next, making multitasking possible with limited CPU cores.
- Long-term scheduling controls system admission; short-term (CPU) scheduling makes the frequent moment-to-moment decision.
- Different scheduling algorithms optimize for different, sometimes conflicting goals like waiting time, fairness, and responsiveness.
- Linux's CFS is a real production scheduler explicitly balancing fairness against interactive responsiveness.
More in Process Scheduling
Browse all Operating Systems topics
Log in to save which topics you've read across every subject.
Frequently asked questions
What is the difference between the long-term and short-term scheduler?
The long-term scheduler decides which processes get admitted into the system at all; the short-term scheduler decides which already-ready process gets the CPU right now, and runs far more frequently.
What are the typical goals a scheduler tries to balance?
Minimizing waiting/turnaround time, maximizing CPU utilization and throughput, ensuring fairness, and providing good responsiveness for interactive processes.
Name a real scheduler used in a production operating system.
Linux's Completely Fair Scheduler (CFS), which tracks each process's accumulated CPU time and favors whichever process has received the least relative to its fair share.
Why can't a scheduler optimize for every goal simultaneously?
Because the goals genuinely conflict, for example, maximizing raw throughput might mean letting long jobs run uninterrupted, while good interactive responsiveness requires frequently interrupting long jobs to service short, latency-sensitive ones.