A multilevel feedback queue (MLFQ) is a CPU scheduling algorithm that keeps several ready queues of different priority and moves each process between them according to its observed behavior. In operating systems, it is the classic answer to a hard problem in processes & scheduling: giving interactive tasks fast response while still letting long CPU-bound jobs finish efficiently, without knowing in advance how long any job will run.
The key idea is learning from history. A process that uses its entire time slice is treated as CPU-bound and is demoted to a lower queue; a process that blocks early for input or output stays near the top. Periodic priority boosts prevent starvation. Variants of this design have shaped the schedulers of Unix, BSD, Solaris and Windows for decades.
How a multilevel feedback queue schedules processes
An MLFQ scheduler always runs the highest-priority non-empty queue first and applies round-robin scheduling among the processes inside that queue. Lower queues run only when every queue above them is empty, so priority is strict between levels and fair within a level.
The feedback comes from a small set of movement rules. A new process enters at the top priority level, because the scheduler assumes it might be short or interactive. If the process consumes its full time allotment at a level, the scheduler concludes that it is CPU-bound and moves it down one level. If it gives up the CPU before the allotment expires, it keeps its level.
The following table summarizes the standard rule set that most textbook and production variants share in some form.
| Rule | Condition | Scheduler action |
|---|---|---|
| Priority order | Two processes in different queues | Run the one in the higher queue |
| Equal priority | Two processes in the same queue | Alternate in round-robin order |
| Entry | A new process arrives | Place it in the top queue |
| Demotion | Process uses its full allotment at a level | Move it one level down |
| Priority boost | A fixed period S elapses | Move all processes to the top queue |
Because a running process at a low level can be preempted the moment a higher queue becomes non-empty, an interactive process that wakes up after a keystroke usually gets the CPU within one short quantum.
Queue levels, time slices and tuning parameters
An MLFQ is defined by its tuning parameters, and the quality of the scheduler depends heavily on choosing them well. Typical designs give short quanta to high queues and progressively longer quanta to low queues, because high queues hold interactive work that needs quick turns while low queues hold batch work that benefits from fewer context switches.
The table below lists the main parameters, a representative range and the behavior each one controls. Exact values differ widely between implementations.
| Parameter | Typical range | What it controls |
|---|---|---|
| Number of queues | 3 to 64 levels | Granularity of priority distinctions |
| Top-level quantum | About 5 to 20 ms | Responsiveness of interactive tasks |
| Bottom-level quantum | About 50 to 200 ms | Throughput and context-switch overhead |
| Allotment per level | One to several quanta | How quickly CPU-bound work sinks |
| Boost period S | About 0.1 to 1 s | Starvation bound and adaptivity |
The boost period is the most delicate value. If it is too long, long-running jobs can starve behind a stream of interactive tasks; if it is too short, CPU-bound jobs return to the top too often and degrade interactive latency. Many designers call such values voodoo constants, because they are set empirically rather than derived.
MLFQ compared with related scheduling algorithms
A multilevel feedback queue combines ideas from several simpler algorithms. It approximates shortest job first without needing job lengths, borrows round-robin scheduling within each level, and uses a form of aging to avoid the starvation that plain priority scheduling suffers from.
| Algorithm | Needs job length | Starvation risk | Interactive response |
|---|---|---|---|
| First-come, first-served | No | None, but long waits | Poor |
| Shortest job first | Yes | High for long jobs | Good if lengths known |
| Round-robin scheduling | No | None | Moderate |
| Static priority scheduling | No | High without aging | Good for high priority |
| Multilevel feedback queue | No, learns it | Low with boosts | Good |
A plain multilevel queue without feedback differs in one decisive way: processes are permanently assigned to a queue, such as system, interactive or batch, and never move. The feedback mechanism is what turns a static classification into an adaptive scheduler.
Gaming, starvation and accounting fixes
Naive MLFQ rules contain two well-known weaknesses. The first is starvation: with many interactive processes, low queues may never run. The periodic priority boost solves this by guaranteeing that every process eventually returns to the top and receives some CPU time.
The second weakness is gaming the scheduler. If demotion happens only when a process uses a whole quantum in one go, a program can issue a trivial I/O request just before the quantum ends and stay at high priority forever. Modern variants fix this with cumulative CPU accounting: the scheduler tracks total time used at a level, regardless of how many times the process yielded, and demotes it once the allotment is spent.
- Behavior changes are handled by boosts, so a batch job that becomes interactive regains high priority.
- Priority inversion can still occur when a low-level process holds a lock that a high-level process needs.
- User hints, such as the Unix nice value, often shift a process’s base level or decay rate.
Multilevel feedback queues in real operating systems
Production schedulers rarely implement the textbook MLFQ exactly, but many inherit its structure. The following table shows how several well-known systems apply the same feedback principle.
| System | Approach | Feedback signal |
|---|---|---|
| Traditional BSD Unix | Priority recomputed from decayed CPU usage | Recent CPU time and nice value |
| Solaris time-sharing class | 60 levels with a dispatch table | Quantum expiry and sleep return |
| Windows NT family | 32 levels with dynamic boosts | I/O completion and foreground focus |
| Linux CFS and EEVDF | Not MLFQ; virtual runtime ordering | Accumulated weighted runtime |
The Linux example is a useful contrast. Its fair schedulers achieve interactive responsiveness through proportional sharing rather than discrete queues, which shows that MLFQ is one solution among several, not the only modern approach.
In simple terms
Think of a busy help desk with several lines. Every new visitor starts in the fast line. If a visitor asks a quick question, they leave quickly. If a visitor needs a long conversation, the clerk moves them to a slower line for longer sessions.
The fast lines are always served first. Every so often, the clerk moves everyone back to the front, so nobody waits forever. In this way, the computer keeps quick tasks snappy and still finishes the long ones.
A practical example
A developer works on a laptop while a video export runs in the background. The text editor wakes up for each keystroke, runs for under a millisecond and then waits again. It never exhausts its allotment, so it stays in the top queue and responds within a few milliseconds.
The video encoder, by contrast, uses every quantum it receives. After a few slices it sinks to the lowest level, where it runs in longer 100 ms quanta whenever the editor and other interactive programs are idle. Each second, a priority boost lifts it briefly to the top, which guarantees progress even during heavy typing. The outcome is a responsive editor and a steadily advancing export, without the user setting any priorities by hand.