CPU Scheduling

What Are the CPU Scheduling Algorithms in Operating Systems?

The main CPU scheduling algorithms grouped by how they work, preemptive or not, and what they use to pick the next process, with a quick comparison table.

On this page
  1. The short answer
  2. Two questions that sort the algorithms
  3. Non-preemptive algorithms
  4. Preemptive algorithms
  5. Multi-queue schemes
  6. Comparison
  7. Which one fits best

The short answer

The common CPU scheduling algorithms in operating systems are first come, first served, shortest job first, priority scheduling, round robin, multilevel queue scheduling, and multilevel feedback queue scheduling. Some courses also count shortest remaining time first as its own algorithm. The list is a teaching convention rather than a fixed standard, so different books may group things a little differently.

Two questions that sort the algorithms

Two questions tell most of them apart:

  1. Can the scheduler take the CPU away from a running process? If not, the algorithm is non-preemptive. If it can, the algorithm is preemptive.
  2. What does the scheduler use to choose the next process? The answer might be arrival order, the expected length of the next CPU burst, a priority number, or which queue a process is in.

Non-preemptive algorithms

  • First come, first served runs processes in arrival order. Once a process has the CPU, it keeps it until it finishes or waits.
  • Shortest job first picks the ready process with the shortest expected next CPU burst. In its basic form, it does not interrupt a running process.
  • Priority scheduling can be run in a non-preemptive form, where the running process keeps the CPU until it stops or waits.

Preemptive algorithms

  • Shortest remaining time first is the preemptive form of shortest job first. A newly ready process with less remaining work than the running one can take the CPU.
  • Round robin gives each process a fixed time slice. When the slice ends, the process goes to the back of the queue.
  • Preemptive priority scheduling lets a higher-priority arrival take the CPU from a lower-priority process.

Multi-queue schemes

Multilevel queue and multilevel feedback queue scheduling keep ready processes in several queues. Each queue usually runs one of the simpler rules above, such as round robin in one queue and first come, first served in another. The feedback version also moves processes between queues based on how they behave.

Comparison

Algorithm Preemptive? What picks the next process Main drawback
First come, first served No Arrival order Short jobs can wait behind a long one (convoy effect)
Shortest job first No (shortest remaining time first is preemptive) Shortest expected next CPU burst Needs burst estimates; long jobs can starve
Priority scheduling Either Highest priority Low-priority processes can starve
Round robin Yes Next process in the queue, each for one time slice Too many switches if the slice is short
Multilevel queue Usually yes Queue order, with its own rule in each queue Processes stay in one queue, which can be rigid
Multilevel feedback queue Yes Queue position, which changes with behavior Harder to tune

Which one fits best

No single algorithm is best for every workload. Simple batch work can run acceptably with first come, first served. Systems with interactive users usually need some form of time slicing, and many combine priorities with time slices. When you study a particular system, check the course material or the system’s documentation, since the exact choice differs.

The complete guide to cpu scheduling

CPU Scheduling Algorithms Explained
Read the guide

Keep exploring

Guides from other topics

All topics →