Sub topic 16
Multilevel Queue and Multilevel Feedback Queue Scheduling
Prerequisites
Assume you know process states, CPU bursts, preemption, priority scheduling, and Round Robin scheduling. You should also be able to draw a Gantt chart and calculate waiting and turnaround time.
Multilevel Queue Scheduling
Multilevel queue (MLQ) scheduling divides the ready queue into separate queues. Each queue represents a process category, such as system processes, interactive processes, or batch processes. A process normally enters one queue and stays there.
The scheduler first chooses between queues. It then applies a scheduling algorithm within the selected queue.
For example:
| Queue | Process type | Policy |
|---|---|---|
| 1 | Interactive | Round Robin |
| 2 | Batch | First-Come First-Served |
If queue 1 has a process ready, queue 2 cannot run when the queues use strict fixed priority. This can cause starvation: a lower-priority queue may wait indefinitely while higher-priority work continues to arrive.
Another design gives each queue a fixed fraction of CPU time. For example, the interactive queue might receive 80% of the CPU and the batch queue 20%. This prevents complete starvation but still protects interactive response time.
Multilevel Feedback Queue
A multilevel feedback queue (MLFQ) also has several ready queues, but processes can move between them. The movement provides feedback about observed CPU behavior.
A common policy is:
- New processes enter the highest-priority queue.
- The highest queue uses a small Round Robin quantum.
- A process that uses its entire quantum moves to a lower queue.
- A process that waits for a long time may move upward.
- Lower queues receive larger quanta, or may use First-Come First-Served.
Short, interactive jobs often finish near the top because they frequently block for input or finish quickly. CPU-bound jobs gradually move downward. Aging, which raises the priority of waiting processes, prevents starvation.
Comparison and Common Errors
MLQ is simpler and more predictable because queue membership is usually fixed. MLFQ adapts better to mixed workloads, but its behavior depends on many parameters: the number of queues, quanta, promotion rules, and demotion rules.
A frequent mistake is assuming that a process moves down merely because it is old. In typical MLFQ policies, consuming a complete quantum causes demotion; waiting too long causes promotion. Always write the queue rules before constructing the schedule.
A second mistake is treating queue priority as process priority without checking the problem statement. Some questions specify strict priority between queues, while others allocate CPU shares.
>callout warning > In an MLFQ problem, identify the initial queue, queue-selection rule, quantum of each queue, demotion condition, and aging condition before calculating any times. >```
Exercise
An MLFQ has a high-priority queue with quantum 2 and a low-priority queue with FCFS. A CPU-bound process uses its first 2 time units completely. What normally happens next?
Show answer
It is preempted and moved to the low-priority queue, where it waits for its next turn under FCFS.