0% found this document useful (0 votes)
3 views7 pages

Multilevel Queue and Multilevel Feedback Queue

Multilevel Queue Scheduling is a CPU scheduling algorithm that assigns processes to fixed priority queues without movement, prioritizing higher queues first. In contrast, Multilevel Feedback Queue Scheduling allows processes to move between queues based on their behavior, dynamically adjusting priorities to favor shorter jobs. While the former is simpler and rigid, the latter is more complex and flexible, accommodating varying process needs.

Uploaded by

aadityajoshi2k5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views7 pages

Multilevel Queue and Multilevel Feedback Queue

Multilevel Queue Scheduling is a CPU scheduling algorithm that assigns processes to fixed priority queues without movement, prioritizing higher queues first. In contrast, Multilevel Feedback Queue Scheduling allows processes to move between queues based on their behavior, dynamically adjusting priorities to favor shorter jobs. While the former is simpler and rigid, the latter is more complex and flexible, accommodating varying process needs.

Uploaded by

aadityajoshi2k5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

UNIT-3

Multilevel Queue Scheduling Algorithm


Definition:
Multilevel Queue Scheduling is a CPU scheduling algorithm where processes are permanently
assigned to one queue based on their type (priority, memory requirements, process type,
etc.). Each queue has its own scheduling algorithm and priority.
The CPU serves the processes in higher priority queues first. Only if a queue is empty, the
CPU moves to a lower priority queue.

Key Concepts:
• Multiple queues are maintained (e.g., foreground, background).
• Each queue can use a different scheduling method (e.g., foreground processes could
use Round Robin; background processes could use FCFS — First-Come, First-Served).
• No movement between queues (in traditional Multilevel Queue scheduling — unlike
in Multilevel Feedback Queue).
• Designed mainly for systems with different types of processes needing different
scheduling treatment.

Working Example:
Suppose we have 3 queues:
1. System processes (Highest priority)
2. Interactive processes (Medium priority)
3. Background jobs (Lowest priority)
• If any System process is available, it will run first.
• Interactive processes will only get the CPU when no system process is in the queue.
• Background jobs run only if both system and interactive queues are empty.

Advantages:
• Easy to design and implement.
• Good for systems where different types of processes need different handling (e.g.,
real-time vs batch jobs).

Disadvantages:
• Rigid: A process stuck in a lower-priority queue may face starvation (may never get
CPU time if high-priority queues are always full).
• No flexibility for processes to "move up" if their behavior changes (this is improved in
Multilevel Feedback Queues).

Multilevel Feedback Queue (MLFQ) Scheduling


Definition:
Multilevel Feedback Queue (MLFQ) scheduling is an advanced CPU scheduling algorithm
where processes can move between multiple queues based on their behavior and execution
history.
It adjusts the priority of processes dynamically:
• Shorter jobs or interactive processes are prioritized.
• Longer CPU-intensive processes are gradually moved to lower priority queues.
Unlike Multilevel Queue scheduling (where processes stay in their queue forever), in MLFQ,
processes can move up or down based on their execution.

Key Properties:
• Multiple Queues ordered by priority.
• Each queue may have a different scheduling algorithm (e.g., Round Robin, FCFS).
• Process movement:
o If a process uses too much CPU time, it is moved to a lower-priority queue.
o If a process waits too long, it may be promoted to a higher-priority queue (to
prevent starvation).

How it Works:
• When a process enters the system, it starts in the highest priority queue.
• If it uses too much CPU time (doesn't finish quickly), it is moved down.
• If it finishes quickly, it stays at higher priority.
• The CPU always selects processes from the highest non-empty queue.

Advantages:
• Dynamic and Flexible.
• Good for interactive systems (like operating systems).
• Short processes get fast response (higher queues).

Disadvantages:
• Complex to implement.
• Need to tune time quanta carefully.
• Risk of starvation for long processes unless aging is used.
Quick Summary:
Multilevel Queue Multilevel Feedback Queue
Fixed queues, no movement Process can move between queues

Static scheduling Dynamic scheduling

Simple design Complex, adaptive design

Example
Multilevel Queue Scheduling (Fixed Queues — NO movement)

Process Arrival Time Burst Time


P1 0 ms 6 ms

P2 1 ms 20 ms

P3 2 ms 25 ms

Assumption:

Queue Process Type Scheduling Algorithm Priority

Q1 System (P1) FCFS High

Q2 Interactive (P2) Round Robin (Quantum = 8 ms) Medium

Q3 Background (P3) FCFS Low

Processes are permanently assigned to their queues.

Scheduling Flow:
• Time 0: P1 arrives → High Priority Queue → Runs first.
• P1 needs 6 ms → completes at time 6.
• Time 1: P2 arrives → Goes to Queue 2 (Interactive).
• Time 2: P3 arrives → Goes to Queue 3 (Background).
Now:
• P1 done → CPU checks next: Queue 2 (Interactive, P2).
• P2 runs Round Robin (Quantum = 8 ms).
1. P2 runs from 6 ms → 14 ms (8 ms used).
2. P2 still has (20-8)=12 ms left.
3. In Round Robin, it can continue or rotate if others exist — since no other
interactive process, P2 continues.
• P2 runs next 8 ms from 14 → 22 ms.
o Now, P2 has 4 ms remaining.
• P2 runs 4 ms from 22 → 26 ms → Finishes.
• Now, CPU checks Queue 3.
• P3 (Background) runs from 26 → (26+25) = 51 ms → Finishes.

Multilevel Feedback Queue Scheduling (Processes CAN move)

Process Arrival Time Burst Time


P1 0 ms 6 ms

P2 1 ms 20 ms

P3 2 ms 25 ms

Assumption:

Queue Scheduling Quantum

Q1 Round Robin 8 ms (High Priority)

Q2 Round Robin 16 ms (Medium Priority)

Q3 FCFS No quantum (Low Priority)

Processes can move down if they use too much time.


Scheduling Flow:
• Time 0: P1 arrives → Starts in Q1 (High Priority).
• P1 needs 6 ms → finishes at time 6 (within quantum).
• Time 1: P2 arrives → Starts in Q1.
• Time 2: P3 arrives → Starts in Q1.
Now:
• Time 6: P2 runs (quantum 8 ms).
o P2 uses 8 ms → from 6 → 14 ms.
o P2 still needs 12 ms → moves to Q2.
• Time 14: P3 runs (quantum 8 ms).
o P3 uses 8 ms → from 14 → 22 ms.
o P3 still needs 17 ms → moves to Q2.
• In Q2:
o Time 22: P2 gets 16 ms quantum.
▪ Needs only 12 ms → finishes by 34 ms.
o Time 34: P3 runs.
▪ Needs 17 ms, has 16 ms quantum.
▪ Runs from 34 → 50 ms.
▪ Remaining 1 ms → moves to Q3.
• In Q3:
o Time 50: P3 finishes last 1 ms → 51 ms.
Major Differences in This Example

Feature Multilevel Queue Multilevel Feedback Queue

Process stays in fixed queue (moves between queues)

P2 stays in same Interactive Queue (P2 moves down)

P3 stays in Background Queue (P3 moves down)

Fairness & adaptability (rigid) (dynamic)

Shorter jobs favored quickly

You might also like