CSE 451: Operating Systems Winter 2003 Lecture 6 Scheduling

Slides:



Advertisements
Similar presentations
Scheduling Criteria CPU utilization – keep the CPU as busy as possible (from 0% to 100%) Throughput – # of processes that complete their execution per.
Advertisements

Operating Systems ECE344 Ding Yuan Scheduling Lecture 10: Scheduling.
Operating Systems CPU Scheduling. Agenda for Today What is Scheduler and its types Short-term scheduler Dispatcher Reasons for invoking scheduler Optimization.
Scheduling in Batch Systems
CS 153 Design of Operating Systems Spring 2015 Lecture 10: Scheduling.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-3 CPU Scheduling Department of Computer Science and Software Engineering.
COT 4600 Operating Systems Spring 2011 Dan C. Marinescu Office: HEC 304 Office hours: Tu-Th 5:00-6:00 PM.
CS 153 Design of Operating Systems Spring 2015 Lecture 11: Scheduling & Deadlock.
1 CSE451 Scheduling Autumn 2002 Gary Kimura Lecture #6 October 11, 2002.
Thread Implementation and Scheduling CSE451 Andrew Whitaker.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Lecture 7: CPU Scheduling Chapter 5.
Processor Scheduling Hank Levy. 22/4/2016 Goals for Multiprogramming In a multiprogramming system, we try to increase utilization and thruput by overlapping.
Lecture Topics: 11/15 CPU scheduling: –Scheduling goals and algorithms.
Lecture 4 CPU scheduling. Basic Concepts Single Process  one process at a time Maximum CPU utilization obtained with multiprogramming CPU idle :waiting.
CPU scheduling.  Single Process  one process at a time  Maximum CPU utilization obtained with multiprogramming  CPU idle :waiting time is wasted 2.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
CPU SCHEDULING.
Dan C. Marinescu Office: HEC 439 B. Office hours: M, Wd 3 – 4:30 PM.
Chapter 5a: CPU Scheduling
Networks and Operating Systems: Exercise Session 2
April 6, 2001 Gary Kimura Lecture #6 April 6, 2001
Scheduling (Priority Based)
CPU Scheduling.
Chapter 6: CPU Scheduling
Process management Information maintained by OS for process management
CPU Scheduling Basic Concepts Scheduling Criteria
CPU Scheduling G.Anuradha
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
Chapter 5: CPU Scheduling
Andy Wang Operating Systems COP 4610 / CGS 5765
Operating System Concepts
CSE 451: Operating Systems Winter 2007 Module 9 Scheduling
CSE 451: Operating Systems Winter 2006 Module 9 Scheduling
CSE 451: Operating Systems Winter 2009 Module 6 Scheduling
3: CPU Scheduling Basic Concepts Scheduling Criteria
Scheduling Adapted from:
Chapter5: CPU Scheduling
TDC 311 Process Scheduling.
CSE 451: Operating Systems Autumn 2009 Module 6 Scheduling
COT 4600 Operating Systems Spring 2011
Chapter 5: CPU Scheduling
Chapter 6: CPU Scheduling
CPU SCHEDULING.
Outline Scheduling algorithms Multi-processor scheduling
COT 4600 Operating Systems Fall 2009
CGS 3763 Operating Systems Concepts Spring 2013
Chapter 5: CPU Scheduling
CSE 451: Operating Systems Spring 2007 Module 6 Scheduling
Processor Scheduling Hank Levy 1.
Process Scheduling B.Ramamurthy 4/11/2019.
Process Scheduling B.Ramamurthy 4/7/2019.
CSE 451: Operating Systems Spring 2006 Module 9 Scheduling
Shortest-Job-First (SJR) Scheduling
Chapter 6: CPU Scheduling
CSE 153 Design of Operating Systems Winter 2019
Concurrency and Threading: CPU Scheduling
Module 5: CPU Scheduling
Chapter 6: Scheduling Algorithms Dr. Amjad Ali
Scheduling 21 May 2019.
CSE 451: Operating Systems Autumn 2010 Module 6 Scheduling
Chapter 6: CPU Scheduling
CSE 451: Operating Systems Winter 2012 Scheduling
CSE 451: Operating Systems Winter 2007 Module 9 Scheduling
CPU Scheduling.
CPU Scheduling: Basic Concepts
Module 5: CPU Scheduling
Chapter 5: CPU Scheduling
CSE 451: Operating Systems Winter 2004 Module 9 Scheduling
CSE 451: Operating Systems Winter 2001 Lecture 6 Scheduling
Presentation transcript:

CSE 451: Operating Systems Winter 2003 Lecture 6 Scheduling Hank Levy levy@cs.washington.edu 412 Sieg Hall 1

Scheduling In discussion process management, we talked about context switching between threads/process on the ready queue but, we glossed over the details of which process or thread is chosen next making this decision is called scheduling scheduling is policy context switching is mechanism Today, we’ll look at: the goals of scheduling starvation well-known scheduling algorithms standard UNIX scheduling 2/25/2019 © 2003 Hank Levy

Multiprogramming and Scheduling Multiprogramming increases resource utilization and job throughput by overlapping I/O and CPU today: look at scheduling policies which process/thread to run, and for how long schedulable entities are usually called jobs processes, threads, people, disk arm movements, … There are two time scales of scheduling the CPU: long term: determining the multiprogramming level how many jobs are loaded into primary memory act of loading in a new job (or loading one out) is swapping short-term: which job to run next to result in “good service” happens frequently, want to minimize context-switch overhead good service could mean many things 2/25/2019 © 2003 Hank Levy

Scheduling The scheduler is the module that moves jobs from queue to queue the scheduling algorithm determines which job(s) are chosen to run next, and which queues they should wait on the scheduler is typically run when: a job switches from running to waiting when an interrupt occurs especially a timer interrupt when a job is created or terminated There are two major classes of scheduling systems in preemptive systems, the scheduler can interrupt a job and force a context switch in non-preemptive systems, the scheduler waits for the running job to explicitly (voluntarily) block 2/25/2019 © 2003 Hank Levy

Scheduling Goals Scheduling algorithms can have many different goals (which sometimes conflict) maximize CPU utilization maximize job throughput (#jobs/s) minimize job turnaround time (Tfinish – Tstart) minimize job waiting time (Avg(Twait): average time spent on wait queue) minimize response time (Avg(Tresp): average time spent on ready queue) Goals may depend on type of system batch system: strive to maximize job throughput and minimize turnaround time interactive systems: minimize response time of interactive jobs (such as editors or web browsers) 2/25/2019 © 2003 Hank Levy

Scheduler Non-goals Schedulers typically try to prevent starvation starvation occurs when a process is prevented from making progress, because another process has a resource it needs A poor scheduling policy can cause starvation e.g., if a high-priority process always prevents a low-priority process from running on the CPU Synchronization can also cause starvation we’ll see this in a future class roughly, if somebody else always gets a lock I need, I can’t make progress 2/25/2019 © 2003 Hank Levy

Algorithm #1: FCFS/FIFO First-come first-served (FCFS) jobs are scheduled in the order that they arrive “real-world” scheduling of people in lines e.g. supermarket, bank tellers, MacDonalds, … typically non-preemptive no context switching at supermarket! jobs treated equally, no starvation except possibly for infinitely long jobs Sounds perfect! what’s the problem? 2/25/2019 © 2003 Hank Levy

FCFS picture Problems: time Job A B C B C Job A Problems: average response time and turnaround time can be large e.g., small jobs waiting behind long ones results in high turnaround time may lead to poor overlap of I/O and CPU 2/25/2019 © 2003 Hank Levy

Algorithm #2: SJF Shortest job first (SJF) choose the job with the smallest expected CPU burst can prove that this has optimal min. average waiting time Can be preemptive or non-preemptive preemptive is called shortest remaining time first (SRTF) Sounds perfect! what’s the problem here? 2/25/2019 © 2003 Hank Levy

SJF Problem Problem: impossible to know size of future CPU burst from your theory class, equivalent to the halting problem can you make a reasonable guess? yes, for instance looking at past as predictor of future but, might lead to starvation in some cases! 2/25/2019 © 2003 Hank Levy

Priority Scheduling Assign priorities to jobs choose job with highest priority to run next if tie, use another scheduling algorithm to break (e.g. FCFS) to implement SJF, priority = expected length of CPU burst Abstractly modeled as multiple “priority queues” put ready job on queue associated with its priority Sound perfect! what’s wrong with this? 2/25/2019 © 2003 Hank Levy

Priority Scheduling: problem The problem: starvation if there is an endless supply of high priority jobs, no low-priority job will ever run Solution: “age” processes over time increase priority as a function of wait time decrease priority as a function of CPU time many ugly heuristics have been explored in this space 2/25/2019 © 2003 Hank Levy

Round Robin Round Robin scheduling (RR) Sounds perfect! ready queue is treated as a circular FIFO queue each job is given a time slice, called a quantum job executes for duration of quantum, or until it blocks time-division multiplexing (time-slicing) great for timesharing no starvation can be preemptive or non-preemptive Sounds perfect! what’s wrong with this? 2/25/2019 © 2003 Hank Levy

RR problems Problems: what do you set the quantum to be? no setting is “correct” if small, then context switch often, incurring high overhead if large, then response time drops treats all jobs equally if I run 100 copies of SETI@home, it degrades your service how can I fix this? 2/25/2019 © 2003 Hank Levy

Combining algorithms Scheduling algorithms can be combined in practice have multiple queues pick a different algorithm for each queue and maybe, move processes between queues Example: multi-level feedback queues (MLFQ) multiple queues representing different job types batch, interactive, system, CPU-bound, etc. queues have priorities schedule jobs within a queue using RR jobs move between queues based on execution history “feedback”: switch from CPU-bound to interactive behavior Pop-quiz: is MLFQ starvation-free? 2/25/2019 © 2003 Hank Levy

UNIX Scheduling Canonical scheduler uses a MLFQ Goals: 3-4 classes spanning ~170 priority levels timesharing: first 60 priorities system: next 40 priorities real-time: next 60 priorities priority scheduling across queues, RR within process with highest priority always run first processes with same priority scheduled RR processes dynamically change priority increases over time if process blocks before end of quantum decreases if process uses entire quantum Goals: reward interactive behavior over CPU hogs interactive jobs typically have short bursts of CPU 2/25/2019 © 2003 Hank Levy