CPU Scheduling

What Are the Six Scheduling Algorithms?

Six CPU scheduling algorithms are commonly taught: FCFS, shortest job first, priority, round robin, multilevel queue and multilevel feedback queue.

On this page
  1. The short answer
  2. Why course lists differ
  3. First come, first served
  4. Shortest job first
  5. Priority scheduling
  6. Round robin
  7. Multilevel queue scheduling
  8. Multilevel feedback queue scheduling
  9. Which to learn first

The short answer

Six CPU scheduling algorithms are taught most often: first come, first served, shortest job first, priority scheduling, round robin, multilevel queue scheduling, and multilevel feedback queue scheduling. Each one decides which ready process runs next, and each suits a different goal.

Why course lists differ

Not every source agrees. Many separate shortest remaining time first, the preemptive form of shortest job first, which brings the count to seven. Others group the methods differently. Treat six as a common teaching set, not an official count.

First come, first served

Processes run in arrival order from a simple queue, and each keeps the CPU until it finishes or waits. The method is easy to build, but it can make short processes wait behind long ones. In one example, three processes arrive at time 0 and need 24, 3 and 3 time units, in that order. The average waiting time is 17 time units.

Shortest job first

This method runs the ready process with the shortest expected next CPU burst. It needs an estimate, because the system cannot know the next burst in advance. In its non-preemptive form, a process that starts keeps the CPU until it finishes. In one example, processes arrive at times 0, 2, 4 and 5 and need 7, 4, 1 and 4 time units. The average waiting time is 4 time units.

The preemptive version, shortest remaining time first, can interrupt a running process when a shorter job is ready. On the same processes, it gives an average of 3 time units. Long jobs can starve if short ones keep arriving.

Priority scheduling

Each process gets a priority, and the scheduler runs the highest-priority ready process. Courses differ on whether a high number or a low number means higher priority, so check which convention is in use. Low-priority processes can starve, and aging fixes this by raising a process’s priority the longer it waits.

Round robin

Each ready process gets one fixed time slice, sometimes called a quantum. If it does not finish, it goes to the back of the queue. Round robin keeps response times reasonable for interactive work.

Using the three-process example with a time slice of 4, the processes wait 6, 4 and 7 time units. That is about 5.7 on average, compared with 17 under first come, first served in the same order. The trade-off is the slice length. Slices that are too short add many switches, and very long slices make the method act like first come, first served.

Multilevel queue scheduling

The ready processes are split into several queues, such as one for interactive work and one for background jobs. Each queue has its own algorithm, and processes usually stay in their assigned queue. This suits systems with clearly different kinds of work, but it is rigid, because a process cannot easily move to a better queue.

Multilevel feedback queue scheduling

This version lets processes move between queues depending on their behavior. A process that uses its whole time slice can be moved to a lower queue, while a process that often waits for input can stay high. Many designs occasionally move processes back to the top to prevent starvation. It is the most flexible of the six, and also the hardest to tune.

Which to learn first

Start with first come, first served and round robin, because they show the basic trade-off between simplicity and fairness. Then move to shortest job first and priority scheduling, which introduce starvation. The multilevel schemes come last, since they combine the earlier rules.

The complete guide to cpu scheduling

CPU Scheduling Algorithms Explained
Read the guide

Keep exploring

Guides from other topics

All topics →

Big O for Data Structures

A practical guide to Big O for data structures: how arrays, lists, hash tables, trees and heaps compare on search, insert and delete costs, with examples.

Big O Notation 5 min read