Operating systems

The Multi-Level Feedback Queue

Prashanth L.A.

2023-08-22

Lecture 8 continues here

How to schedule without perfect knowledge?

MLFQ in words

 

Rule Description
Rule 1 If Priority(A) \(>\) Priority(B), A runs
Rule 2 If Priority(A) \(=\) Priority(B), A and B run in RR

MLFQ in 1000 words worth

Problems

First fix

More on the first fix: How to change priority

Rule Description
Rule 3 When a job enters the system, it is placed at the highest priority
Rule 4a If a job uses up an entire time slice while running, its priority is reduced
Rule 4b If a job gives up the CPU before the time slice is up, it stays at the same priority level

Example 1: A long-running job

Enter at highest priority and then go down

Example 2: Along Came a Short Job

Main idea

Example 3: Jobs with I/O

Problems

Starvation

Too many interactive jobs consuming all CPU time. Long running jobs don’t ever run

Games processes play

The name of the process is change

Lecture 9 starts here

Second fix: Boosting the priority

Rule Description
Rule 5 After some time period \(S\), move all the jobs to the topmost queue

 

Example 4: Jobs with I/O

Does new Rule 4 solve some problems?

Last fix: Track process usage

Rule Description
Rule 4 Once a job uses up its time allotment at a given level (regardless of how many times it has given up the CPU), its priority is reduced

Regardless of the I/O behavior of the process, it slowly moves down the queues \(\Rightarrow\) cannot gain an unfair CPU share

Tuning MLFQ

No easy answers, try different workloads to tune MLFQ

Varying timeslices

Summary

Rule Description
Rule 1 If Priority(A) \(>\) Priority(B), A runs
Rule 2 If Priority(A) \(=\) Priority(B), A and B run in RR.
Rule 3. When a job enters the system, it is placed at the highest priority
Rule 4 Once a job uses up its time allotment at a given level, its priority is reduced
Rule 5 After some time period \(S\), move all the jobs to the topmost queue