A topic in the Open Knowledge Graph — a free, open map of 15,290 topics and the order to learn them in.

Multilevel Feedback Queue (MLFQ) Scheduling

College Depth 103 in the knowledge graph ☐ I know this ☆ Set as goal
1topic build on this
369prerequisites beneath it
See this on the map →
Shortest Job First (SJF) CPU SchedulingPriority Scheduling Algorithms→→Real-Time Scheduling Algorithms
scheduling algorithms cpu feedback

Core Idea

MLFQ uses multiple queues with different priorities and time quanta, allowing processes to move between queues based on behavior. Processes that consume their full time slice move to lower-priority queues, while I/O-bound processes stay in higher-priority queues. This design approximates SJF without requiring prior knowledge of burst times.

How It's Best Learned

Trace through MLFQ scheduling with varying process behaviors. Experiment with different queue structures and time quantum combinations. Compare against SJF and round-robin to understand trade-offs.

Common Misconceptions

Explainer

From your study of Shortest Job First scheduling, you know that SJF produces optimal average waiting times — but it has a fatal practical flaw: it requires knowing how long each job will run *before* it runs. In real operating systems, the kernel has no idea whether the process that just became ready will use the CPU for 2 milliseconds or 2 seconds. Multilevel Feedback Queue (MLFQ) scheduling solves this by *observing* process behavior and adjusting priority dynamically, effectively learning which processes are short and interactive versus long and CPU-bound.

The structure is a set of queues arranged by priority level. A new process enters the highest-priority queue with a small time quantum (say 8ms). If it finishes its CPU burst before the quantum expires — perhaps because it issued an I/O request — it stays at the same high priority. The system infers that this process is interactive or I/O-bound, and interactive processes need fast response times. But if the process uses its entire quantum without voluntarily yielding, the scheduler demotes it to the next lower queue, which has a larger time quantum (say 16ms). If it burns through that quantum too, it drops again. Eventually, long-running CPU-bound processes sink to the lowest-priority queue with the largest time quantum, where they run less frequently but get larger chunks of CPU time when they do run.

This design elegantly approximates SJF without requiring advance knowledge. Short jobs finish quickly in the high-priority queue and never get demoted. Long jobs gradually sink to lower queues where they don't interfere with interactive responsiveness. I/O-bound processes (like a text editor waiting for keystrokes) naturally stay at high priority because they frequently yield the CPU before their quantum expires. The scheduler gives preferential treatment to exactly the processes that need it: those with short, bursty CPU usage patterns that would suffer most from delayed scheduling.

The main pitfall is starvation: if enough high-priority processes keep arriving, the low-priority queues never get to run. The standard solution is a priority boost — periodically (say every second), the scheduler moves all processes back to the highest-priority queue. This gives long-running processes a fresh chance to run and also handles processes whose behavior changes over time (a computation phase might end and the process might become interactive). Another concern is gaming: a clever process could issue a trivial I/O request just before its quantum expires, tricking the scheduler into keeping it at high priority while monopolizing the CPU. Modern MLFQ implementations track total CPU time per priority level rather than just per-quantum behavior to prevent this. Nearly every general-purpose OS uses some variant of MLFQ — Linux's CFS and Windows' priority scheduling both incorporate feedback-based priority adjustment, because the principle of "observe and adapt" is fundamentally more robust than requiring predictions about future behavior.

Practice Questions 5 questions

Prerequisite Chain

Understanding Zero → The Number Zero → Counting to Five → Counting to 10 → Counting to 20 → Counting a Set of Objects Up to 20 → Cardinality: The Last Number Counted → Matching Numerals to Quantities → Subitizing Small Quantities → Addition Within 10 → Number Bonds to 10 → Addition Within 20 → Doubles and Near Doubles → Doubles Facts Within 10 → Near Doubles Facts Within 20 → Mental Math Strategies for Addition → Mental Math: Adding and Subtracting Tens → Addition Within 100 → Repeated Addition as Multiplication → Multiplication as Equal Groups → Multiplication: Arrays → Basic Multiplication Facts (0s, 1s, 2s, 5s, 10s) → Multiplication Facts Within 100 → Division as Equal Sharing → Division as Grouping (Measurement Division) → Division: Grouping (Repeated Subtraction) Model → Division: Fair Sharing Model → Division as Equal Sharing → Division as Grouping → Basic Division Facts → Division Facts Within 100 → Multiplication and Division Fact Families → Relationship Between Multiplication and Division → Division Facts as Inverse of Multiplication → Remainders and Quotients in Division → Division Word Problems → Multi-Step Word Problems → Solving Multi-Step Word Problems → Multiplication Word Problems → Division Word Problems → Introduction to Long Division → Factors and Multiples → Prime and Composite Numbers → Equivalent Fractions → Relating Fractions and Decimals → Decimal Place Value → Integers and the Number Line → Comparing and Ordering Integers → Absolute Value → Adding Integers → Subtracting Integers → Multiplying Integers → Introduction to Exponents → Order of Operations → Integer Order of Operations → Variable Expressions → The Distributive Property → Variables and Expressions Review → Introduction to Polynomials → Adding and Subtracting Polynomials → Multiplying Polynomials → Factorial → Permutations → Combinations → Counting Principles: Addition and Multiplication Rules → Introduction to Graph Theory → Propositional Logic Foundations → Logical Equivalences → Boolean Algebra → Boolean Type and Truth Values → Comparison Operators and Boolean Tests → Logical Operators and Boolean Algebra → Boolean Algebra and Fundamental Laws → Logic Gates Fundamentals → Implementing Boolean Functions with Gates → Karnaugh Map Simplification → Combinational Circuit Design → Flip-Flops and Latches → Binary Counters: Design and Analysis → Binary Arithmetic → Fixed-Point Number Representation → Two's Complement Representation → Overflow and Underflow Detection → Binary Adders: Half-Adders and Full-Adders → Full Adder and Carry Propagation → Carry Lookahead Adder Design → Half Adder Circuit Design → Multiplication Circuit Design → Sequential Circuit Design → Registers and Register Files → Instruction Set Architecture (ISA) → Kernel Architecture and OS Structure → System Calls and User/Kernel Mode → Processes and the Process Control Block → Process Creation: fork() and exec() → Process Termination and Resource Cleanup → Process States and State Transitions → Process Model Formalization → Context Switching and CPU Dispatch → CPU Scheduling Fundamentals → Round-Robin (RR) Scheduling → First-Come-First-Served (FCFS) Scheduling → Priority Scheduling Algorithms → Multilevel Feedback Queue (MLFQ) Scheduling

Longest path: 104 steps · 369 total prerequisite topics

Prerequisites (2)

Leads To (1)