Multilevel Queue (MLQ) CPU Scheduling
The Multilevel Queue (MLQ) CPU Scheduling algorithm is an approach
used by operating systems to partition the ready queue—where
processes wait for the CPU—into several separate queues. Each
queue is dedicated to a specific class of processes, and each has its
own distinct scheduling algorithm and priority level.
The ready queue is divided into multiple independent queues.
Types of Processes in a Computer:
1. System Processes
2. Interactive Processes
3. Batch Processes
System Processes (Highest Priority): These are the core OS services that
keep the computer running
Memory management (allocating RAM)
Process scheduling (deciding which program runs next)
Device drivers (keyboard, mouse, disk controller)
Interactive Processes: These are user-facing tasks that must
respond quickly.
Text editor (Notepad) responds to keystrokes instantly.
→
Web browser (Chrome, Firefox) loads pages and reacts to clicks.
→
Games need fast response to inputs.
→
Batch Processes (Lowest Priority):These are long, background
jobs that don’t need instant results.
Data backup copying files to an external drive.
→
Log analysis scanning system logs for errors.
→
Print jobs documents queued to the printer.
→
Each queue can use its own scheduling algorithm best suited for its
processes:
• No process in a lower-priority queue can run unless all
higher-priority queues are empty.
• If a process arrives in a high-priority queue while a low-
priority process is running, the low-priority process is
preempted (interrupted).
Example:
Consider a system with two queues:
Queue 1 (Q1): Interactive/Foreground Processes (Highest
Priority)
Scheduling Algorithm: Round Robin (RR) with a time quantum (Tq​
)
of 2 ms.
Queue 2 (Q2): Batch/Background Processes (Lower Priority)
Scheduling Algorithm: First-Come, First-Served (FCFS).
Process ID
Arrival Time
(ms)
CPU Burst
Time (ms)
Assigned Queue
P1​ 0 4 Q1
P2​ 0 3 Q1
P3​ 0 8 Q2
P4​ 10 5 Q1
• Time 0Ready Processes: P1​
,P2​(in Q1); P3​(in Q2).
• Decision: Q1 is highest priority. P1​arrived first in Q1.
• Action: P1​runs for its Tq​
=2 ms.
• P1​Remaining Burst: 4 2=2 ms.
−
Time (ms) Event Ready Queue (Q1: RR) Ready Queue (Q2: FCFS) CPU (Running) Remaining Bursts
0 P1​
,P2​
,P3​Arrive [P1​
,P2​
] [P3​
] P1​(Start) P1​
:4,P2​
:3,P3​
:8
2 P1​Preempted (TQ) [P2​
,P1​
] [P3​
] P2​(Start) P1​
:2,P2​
:3,P3​
:8
4 P2​Preempted (TQ) [P1​
,P2​
] [P3​
] P1​(Resume) P1​
:2,P2​
:1,P3​
:8
6 P1​Completes [P2​
] [P3​
] P2​(Resume) P2​
:1,P3​
:8
7 P2​Completes [] [P3​
] P3​(Start) P3​
:8
10 P4​Arrives & P3​Preempted [P4​
] [P3​
] P4​(Start) P3​
:5,P4​
:5
12 P4​Preempted (TQ) [P4​
] [P3​
] P4​(Resume) P3​
:5,P4​
:3
14 P4​Preempted (TQ) [P4​
] [P3​
] P4​(Resume) P3​
:5,P4​
:1
15 P4​Completes [] [P3​
] P3​(Resume) P3​
:5
20 P3​Completes [] [] Idle All Completed
Final Gantt Chart
P1​ P2​ P1​ P2​ P3​ P4​ P4​ P4​ P3​
0 2 4 6 7 10 12 14 15

Multilevel Queue (MLQ) CPU Scheduling.pptx

  • 1.
    Multilevel Queue (MLQ)CPU Scheduling The Multilevel Queue (MLQ) CPU Scheduling algorithm is an approach used by operating systems to partition the ready queue—where processes wait for the CPU—into several separate queues. Each queue is dedicated to a specific class of processes, and each has its own distinct scheduling algorithm and priority level.
  • 2.
    The ready queueis divided into multiple independent queues. Types of Processes in a Computer: 1. System Processes 2. Interactive Processes 3. Batch Processes System Processes (Highest Priority): These are the core OS services that keep the computer running Memory management (allocating RAM) Process scheduling (deciding which program runs next) Device drivers (keyboard, mouse, disk controller)
  • 3.
    Interactive Processes: Theseare user-facing tasks that must respond quickly. Text editor (Notepad) responds to keystrokes instantly. → Web browser (Chrome, Firefox) loads pages and reacts to clicks. → Games need fast response to inputs. → Batch Processes (Lowest Priority):These are long, background jobs that don’t need instant results. Data backup copying files to an external drive. → Log analysis scanning system logs for errors. → Print jobs documents queued to the printer. → Each queue can use its own scheduling algorithm best suited for its processes:
  • 4.
    • No processin a lower-priority queue can run unless all higher-priority queues are empty. • If a process arrives in a high-priority queue while a low- priority process is running, the low-priority process is preempted (interrupted).
  • 5.
    Example: Consider a systemwith two queues: Queue 1 (Q1): Interactive/Foreground Processes (Highest Priority) Scheduling Algorithm: Round Robin (RR) with a time quantum (Tq​ ) of 2 ms. Queue 2 (Q2): Batch/Background Processes (Lower Priority) Scheduling Algorithm: First-Come, First-Served (FCFS).
  • 6.
    Process ID Arrival Time (ms) CPUBurst Time (ms) Assigned Queue P1​ 0 4 Q1 P2​ 0 3 Q1 P3​ 0 8 Q2 P4​ 10 5 Q1
  • 7.
    • Time 0ReadyProcesses: P1​ ,P2​(in Q1); P3​(in Q2). • Decision: Q1 is highest priority. P1​arrived first in Q1. • Action: P1​runs for its Tq​ =2 ms. • P1​Remaining Burst: 4 2=2 ms. −
  • 8.
    Time (ms) EventReady Queue (Q1: RR) Ready Queue (Q2: FCFS) CPU (Running) Remaining Bursts 0 P1​ ,P2​ ,P3​Arrive [P1​ ,P2​ ] [P3​ ] P1​(Start) P1​ :4,P2​ :3,P3​ :8 2 P1​Preempted (TQ) [P2​ ,P1​ ] [P3​ ] P2​(Start) P1​ :2,P2​ :3,P3​ :8 4 P2​Preempted (TQ) [P1​ ,P2​ ] [P3​ ] P1​(Resume) P1​ :2,P2​ :1,P3​ :8 6 P1​Completes [P2​ ] [P3​ ] P2​(Resume) P2​ :1,P3​ :8 7 P2​Completes [] [P3​ ] P3​(Start) P3​ :8 10 P4​Arrives & P3​Preempted [P4​ ] [P3​ ] P4​(Start) P3​ :5,P4​ :5 12 P4​Preempted (TQ) [P4​ ] [P3​ ] P4​(Resume) P3​ :5,P4​ :3 14 P4​Preempted (TQ) [P4​ ] [P3​ ] P4​(Resume) P3​ :5,P4​ :1 15 P4​Completes [] [P3​ ] P3​(Resume) P3​ :5 20 P3​Completes [] [] Idle All Completed
  • 9.
    Final Gantt Chart P1​P2​ P1​ P2​ P3​ P4​ P4​ P4​ P3​ 0 2 4 6 7 10 12 14 15