430 likes | 852 Views
Scheduling: The Multi-Level Feedback Queue. SeongJae Park (sjpark@dcslab.snu.ac.kr) School of Computer Science and Engineering Seoul National University. MLFQ: Multi-Level Feedback Queue. Described by Corbato et al. in 1962 “An Experimental Time-Sharing System”
E N D
Scheduling:The Multi-Level Feedback Queue SeongJae Park (sjpark@dcslab.snu.ac.kr) School of Computer Science and Engineering Seoul National University
MLFQ: Multi-Level Feedback Queue • Described by Corbato et al. in 1962 • “An Experimental Time-Sharing System” • Goal 1: Short turnaround time • SJF(Shortest-Job First) do best for the goal • However, could not know whether a job is will finish soon or not • Goal 2: Minimal response time • Users should receive response to their keyboard / mouse input quickly
MLFQ: Basic Rule A job have priority If Priority(A) > Priority(B), A runs If Priority(A) == Priority(B), A & B runs in Round-Robin
MLFQ: Priority Implementation Q8 A B Higher Priority Q7 C … Q1 D Insert Jobs with same priority in same queue
MLFQ v1: Priority Change If Priority(A) > Priority(B), A runs If Priority(A) == Priority(B), A & B runs in Round-Robin When a job enters the system, it is placed at the highest priority If a job uses up an entire time slice while running, its priority is reduced If a job gives up the CPU before the time slice is up, it stays at the same priority level
Long-running job on MLFQ v1 Q2 Q1 Q0 0 50 100 Time slice: 10 ms
Long-running job on MLFQ v1 Used entire time slice… Q2 Q1 Q0 0 50 100 Time slice: 10 ms
Long-running job on MLFQ v1 Q2 Used entire time slice… Q1 Q0 0 50 100 Time slice: 10 ms
Long-running / Short-running jobs on MLFQ v1 Q2 Q1 Q0 0 50 100 Time slice: 10 ms
Long-running / Short-running jobs on MLFQ v1 New job start from highest priority Q2 Q1 Q0 0 50 100 Time slice: 10 ms
Long-running / Short-running jobs on MLFQ v1 Used entire time slice… Q2 Q1 Q0 0 50 100 Time slice: 10 ms
Long-running / Short-running jobs on MLFQ v1 Job finished! Q2 Q1 Q0 0 50 100 Time slice: 10 ms
Long-running / Interactive jobs on MLFQ v1 Q2 Q1 Q0 0 50 100 Time slice: 10 ms
Long-running / Interactive jobs on MLFQ v1 Q2 Q1 Q0 0 50 100 Time slice: 10 ms
Long-running / Interactive jobs on MLFQ v1 Q2 Q1 Q0 0 50 100 Time slice: 10 ms
Long-running / Interactive jobs on MLFQ v1 Q2 Q1 Q0 0 50 100 Time slice: 10 ms
Problem of MLFQ v1: Starvation Q2 Q1 Q0 0 50 100 150 200 Long-running job could be starved by too many interactive jobs Time slice: 10 ms
Problem of MLFQ v1: Starvation Q2 Q1 Q0 0 50 100 150 200 Long-running job could be starved by too many interactive jobs Time slice: 10 ms
Problem of MLFQ v1: Starvation Q2 Q1 Q0 0 50 100 150 200 Long-running job could be starved by too many interactive jobs Time slice: 10 ms
Problem of MLFQ v1: Starvation Q2 Q1 Q0 0 50 100 150 200 Long-running job could be starved by too many interactive jobs Time slice: 10 ms
Problem of MLFQ v1: Starvation Q2 Q1 Q0 0 50 100 150 200 Long-running job could be starved by too many interactive jobs Time slice: 10 ms
MLFQ v2: Boost Priority If Priority(A) > Priority(B), A runs If Priority(A) == Priority(B), A & B runs in Round-Robin When a job enters the system, it is placed at the highest priority If a job uses up an entire time slice while running, its priority is reduced If a job gives up the CPU before the time slice is up, it stays at the same priority level After some time period S, change priority of all the jobs in the system to the highest priority
Long-running / Many interactive jobs on MLFQ v2 Q2 Q1 Q0 0 50 100 150 200 Time slice: 10 ms
Long-running / Many interactive jobs on MLFQ v2 Priority boost! Q2 Q1 Q0 0 50 100 150 200 Time slice: 10 ms
Long-running / Many interactive jobs on MLFQ v2 Q2 Q1 Q0 0 50 100 150 200 Time slice: 10 ms
Long-running / Many interactive jobs on MLFQ v2 Priority boost! Q2 Q1 Q0 0 50 100 150 200 Time slice: 10 ms
Problem of MLFQ v2: Gaming CPU Q2 Q1 Uses 9 msecs and gives back CPU :P Q0 0 50 100 150 200 A jobs could abuse scheduler by giving up CPU before time slice up Time slice: 10 ms
MLFQ v3: Account CPU time If Priority(A) > Priority(B), A runs If Priority(A) == Priority(B), A & B runs in Round-Robin When a job enters the system, it is placed at the highest priority If a job uses up an entire time slice while running, its priority is reduced If a job gives up the CPU before the time slice is up, it stays at the same priority level Once a jobs uses up its time allotment at a given level, its priority is reduced After some time period S, change priority of all the jobs in the system to the highest priority
Gaming tolerance on MLFQ v3 Q2 Q1 Q0 0 50 100 150 200 Time slice: 10 ms
MLFQ Parameterization Problem • MLFQ should be parameterized well • Number of queues • Time slice • Priority boost period • Wrong configuration could cause wrong scheduling behavior
MLFQ Parameterization Problem • MLFQ should be parameterized well • Number of queues • Time slice • Priority boost period • Wrong configuration could cause wrong scheduling behavior • General Solutions • Shorter time slice to higher priority queue • Provides configuration feature and default configuration • Uses mathematical formulae • Let user advice scheduler
MLFQ Parameterization of Solaris, FreeBSD • Solaris • Make configurable and gives default configuration • Default configuration of Solaris MLFQ • 60 queues, 20 – few hundred milliseconds time slices, 1 second priority boost period
MLFQ Parameterization of Solaris, FreeBSD • Solaris • Make configurable and gives default configuration • Default configuration of Solaris MLFQ • 60 queues, 20 – few hundred milliseconds time slices, 1 second priority boost period • FreeBSD • Uses mathematical formulae based on CPU usage • CPU usage is decayed for priority boost like effect
Summary • MLFQ(Multiple Level Feedback Queue) Scheduler • Has multiple levels of queues • Uses feedback to determine the priority of a given job • Deliver excellent overall performance for short-running interactive jobs • Fair and makes progress for long-running CPU-intensive workloads