Scheduling: Th e Multi Level Feedback Queue
E N D
Presentation Transcript
Scheduling:The Multi Level Feedback Queue Ilsoo Byun(isbyun@dcslab.snu.ac.kr) School of Computer Science and Engineering Seoul National University
Outline Introduction Basic Rules Summary
Introduction • Invented by Corbato • Lead to award him the “Turing Award” • Schedule without perfect knowlede • Approximate SJF (Shortest Job First) • Optimize turnaround time • Minimize reponse time
MLFQ: Basic Rules High Priority B A Q4 Q3 C Q2 D Q1 Processor Low Priority Rule 1. If Priority(A) > Priority(C), A runs Rule 2. If Priority(A) = Priority(B), A & B run in RR
Attempt #1: How To Change Priority Rule 3: When a job enters the system, it is placed at the highest priority. (the topmost queue) 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 Single Long-Running Job Q2 Q1 Q0 10ms 10ms Scheduler first assumes a job might be short. If it’s not, the job will slowly move down the queues.
Example 2: Along Came A Short Job A Process B Process Q2 Q1 Q0 10ms 10ms If a job is actually short, It will run quickly and complete.
Example 3: What About I/O? A Process B Process Q2 Q1 Q0 If a job gives up the processor before using up its timeslice, It will stay at the same priority level.
Problems With Our Current MLFQ (1) A Process B Process Q2 Q1 Q0 • To game the scheduler • Trick the scheduler to get more than its fair share of the resource
Attempt #2: Better Accounting A Process You exhausted your share B Process Q2 You exhausted your share Q1 Q0 Rule 4: Once a job uses up its time allotment at a given level, its priority is reduced.
Problems With Our Current MLFQ (2) A Process B Process C Process Q2 Q1 Q0 I’m hungry • Starvation • If there are too many interactive jobs, long running jobs will never receive any CPU time.
Attempt #3: The Priority Boost Boost! Boost! Boost! Q2 A Process B Process Q1 C Process Q0 0 50 100 200 150 Rule 5: After some time period S, move all the jobs in the system to the topmost queue.
Summary • MLFQ approximates SJF • MLFQ Basic Rules • Rule 1: If Priority(A) > Priority(C), A runs • Rule 2: If Priority(A) = Priority(B), A & B run in RR • Rule 3: When a job enters the system, it is placed at the highest priority. (the topmost queue) • 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 in the system to the topmost queue.