U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Operating Systems CMPSCI 377 Lecture.

Slides:



Advertisements
Similar presentations
Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D.
Advertisements

CPU Scheduling Questions answered in this lecture: What is scheduling vs. allocation? What is preemptive vs. non-preemptive scheduling? What are FCFS,
CPU Scheduling CPU Scheduler Performance metrics for CPU scheduling
Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D.
Operating Systems Chapter 6
CPU Scheduling Section 2.5.
Day 25 Uniprocessor scheduling. Algorithm: Selection function Selection function – which process among ready processes to select. w – time spent in system,
CENG 334 – Operating Systems 05- Scheduling
Operating Systems 1 K. Salah Module 2.1: CPU Scheduling Scheduling Types Scheduling Criteria Scheduling Algorithms Performance Evaluation.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts Amherst Operating Systems CMPSCI 377 Lecture.
Scheduling in Batch Systems
Project 2 – solution code
CPU Scheduling. Schedulers Process migrates among several queues –Device queue, job queue, ready queue Scheduler selects a process to run from these queues.
Chapter 2 Processes and Threads Scheduling Classical Problems.
CS 104 Introduction to Computer Science and Graphics Problems Operating Systems (2) Process Management 10/03/2008 Yang Song (Prepared by Yang Song and.
Job scheduling Queue discipline.
CPU Scheduling Prof. Sirer (dr. Willem de Bruijn) CS 4410 Cornell University.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Operating Systems CMPSCI 377 Lecture.
1 Scheduling Algorithms FCFS First-Come, First-Served Round-robin SJF Multilevel Feedback Queues.
1Chapter 05, Fall 2008 CPU Scheduling The CPU scheduler (sometimes called the dispatcher or short-term scheduler): Selects a process from the ready queue.
Threads & Scheduling What are threads?
Chapter 5: Process Scheduling
CPU-Scheduling Whenever the CPU becomes idle, the operating system must select one of the processes in the ready queue to be executed. The short term scheduler.
Recall … Process states –scheduler transitions (red) Challenges: –Which process should run? –When should processes be preempted? –When are scheduling decisions.
CPU Scheduling Chapter 6 Chapter 6.
Chapter 6: CPU Scheduling
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-3 CPU Scheduling Department of Computer Science and Software Engineering.
10CSE CPU Scheduling Copyrights Lecture Slides adapted from “ Advanced Operating Systems ”, Lecture Notes by Prof. Prof. Daniel Mosse, University Of Pittsburgh,
CS212: OPERATING SYSTEM Lecture 3: Process Scheduling 1.
COT 4600 Operating Systems Spring 2011 Dan C. Marinescu Office: HEC 304 Office hours: Tu-Th 5:00-6:00 PM.
Chapter 6 CPU SCHEDULING.
1 Scheduling Processes. 2 Processes Each process has state, that includes its text and data, procedure call stack, etc. This state resides in memory.
Operating Systems Lecture Notes CPU Scheduling Matthew Dailey Some material © Silberschatz, Galvin, and Gagne, 2002.
Scheduling. Alternating Sequence of CPU And I/O Bursts.
1 CSE451 Scheduling Autumn 2002 Gary Kimura Lecture #6 October 11, 2002.
CPU Scheduling CSCI 444/544 Operating Systems Fall 2008.
1 Our focus  scheduling a single CPU among all the processes in the system  Key Criteria: Maximize CPU utilization Maximize throughput Minimize waiting.
S CHEDULING A LGORITHMS Dr. Adil Yousif 1. CPU S CHEDULING How is the OS to decide which of several tasks to take off a queue? Scheduling: deciding which.
Process A program in execution. But, What does it mean to be “in execution”?
Lecture 7: Scheduling preemptive/non-preemptive scheduler CPU bursts
Operating Systems Scheduling. Bursts of CPU usage alternate with periods of waiting for I/O. (a) A CPU-bound process. (b) An I/O-bound process. Scheduling.
Operating Systems 1 K. Salah Module 2.2: CPU Scheduling Scheduling Types Scheduling Criteria Scheduling Algorithms Performance Evaluation.
1 Computer Systems II Process Scheduling. 2 Review of Process States.
ITFN 2601 Introduction to Operating Systems Lecture 4 Scheduling.
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.
Scheduling Algorithms : Important Aspects Minimize Response Time –Elapsed time to do an operation (job) –Response time is what the user sees Time to echo.
CS333 Intro to Operating Systems Jonathan Walpole.
1 CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling.
Operating Systems Scheduling. Scheduling Short term scheduler (CPU Scheduler) –Whenever the CPU becomes idle, a process must be selected for execution.
Lecture 4 CPU scheduling. Basic Concepts Single Process  one process at a time Maximum CPU utilization obtained with multiprogramming CPU idle :waiting.
Lecture 12 Scheduling Models for Computer Networks Dr. Adil Yousif.
CPU Scheduling G.Anuradha Reference : Galvin. CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time.
Process Scheduling. Scheduling Strategies Scheduling strategies can broadly fall into two categories  Co-operative scheduling is where the currently.
CPU scheduling.  Single Process  one process at a time  Maximum CPU utilization obtained with multiprogramming  CPU idle :waiting time is wasted 2.
3. CPU Scheduling. CPU Scheduling Process execution – a cycle of CPU execution and I/O wait – figure Preemptive Non-Preemptive.
Lecture 5 Scheduling. Today CPSC Tyson Kendon Updates Assignment 1 Assignment 2 Concept Review Scheduling Processes Concepts Algorithms.
Lecturer 5: Process Scheduling Process Scheduling  Criteria & Objectives Types of Scheduling  Long term  Medium term  Short term CPU Scheduling Algorithms.
Scheduling.
Chapter 5: CPU Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 5: CPU Scheduling Basic Concepts Scheduling Criteria.
CPU Scheduling Andy Wang Operating Systems COP 4610 / CGS 5765.
CPU Scheduling Scheduling processes (or kernel-level threads) onto the cpu is one of the most important OS functions. The cpu is an expensive resource.
CPU SCHEDULING.
Scheduling (Priority Based)
CPU Scheduling.
Andy Wang Operating Systems COP 4610 / CGS 5765
CSE 451: Operating Systems Winter 2003 Lecture 6 Scheduling
Concurrency and Threading: CPU Scheduling
Don Porter Portions courtesy Emmett Witchel
CSE 451: Operating Systems Winter 2001 Lecture 6 Scheduling
Presentation transcript:

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Operating Systems CMPSCI 377 Lecture 6: Scheduling

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 2 Last Time: Threads & Scheduling Thread = execution stream within process User-level, kernel-level, hybrid No perfect scheduling algorithm Policy decision Goals: Minimize response time Maximize throughput Fairness

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 3 This Time: Scheduling Algorithms FCFS First-Come, First-Served Round-robin SJF Multilevel Feedback Queues Lottery Scheduling

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 4 Round-Robin Scheduling Quantum expires: move to back of queue Variants used in most real systems Tradeoffs: length of quantum Large: response time increases quantum ) 1 = FCFS Small: throughput decreases quantum ) 0 = overhead dominates context switches, cache misses

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 5 Example: Round-Robin waiting running

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 6 Example: Round-Robin waiting running

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 7 Example: Round-Robin waiting running

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 8 Example: Round-Robin waiting running

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 9 Example: Round-Robin waiting running

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 10 Example: Round-Robin waiting running

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 11 Example: Round-Robin waiting running

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 12 Example: Round-Robin waiting running

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 13 Example: Round-Robin waiting running

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 14 Example: Round-Robin waiting running

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 15 Example: Round-Robin waiting running + Fair - Long average wait times

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 16 Round-Robin vs. FCFS Example 1: 5 jobs, 100 seconds each, quantum = 1s ignore context switch time

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 17 Round-Robin vs. FCFS Example 1: 5 jobs, 100 seconds each, quantum = 1s ignore context switch time

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 18 Round-Robin vs. FCFS Example 2: 5 jobs: 50, 40, 30, 20, 10 seconds each

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 19 Round-Robin vs. FCFS Example 2: 5 jobs: 50, 40, 30, 20, 10 seconds each

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 20 This Time: Scheduling Algorithms FCFS First-Come, First-Served Round-robin SJF Multilevel Feedback Queues Lottery Scheduling

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 21 Example: SJF Schedule job with least work until I/O or done

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 22 Example: SJF Schedule job with least work until I/O or done

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 23 Example: SJF Schedule job with least work until I/O or done

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 24 Example: SJF Schedule job with least work until I/O or done

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 25 Example: SJF Schedule job with least work until I/O or done

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 26 Example: SJF Schedule job with least work until I/O or done

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 27 Example: SJF 5 jobs, length 50, 40, 30, 20, 10 seconds

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 28 Example: SJF 5 jobs, length 50, 40, 30, 20, 10 seconds

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 29 SJF/SRTF: Shortest-Job First Advantages: Provably optimal – minimizes average waiting time Works for preemptive & non-preemptive schedulers Preemptive SJF = SRTF Shortest remaining time first I/O-bound jobs get priority over CPU-bound jobs Disadvantages: Impossible to predict CPU time job has left Long-running CPU-bound jobs can starve

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 30 This Time: Scheduling Algorithms FCFS First-Come, First-Served Round-robin SJF Multilevel Feedback Queues Lottery Scheduling

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 31 Multilevel Feedback Queues (MLFQ) Use past behavior to predict future, assign job priorities Overcome prediction problem in SJF Assumption: I/O-bound in past, I/O-bound in future Scheduler favors jobs that used least CPU time Adaptive: Change in behavior ) change in scheduling decisions

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 32 MLFQ: Approximating SJF Multiple queues, different priorities Round-robin scheduling at each priority level Run all at highest priority first, then next, etc. Can lead to starvation Increase quantum exponentially at lower priorities

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 33 MLFQ Example

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 34 MLFQ: Assigning Priorities Job starts in highest priority queue Quantum expires ) CPU-bound Drop priority one level Quantum does not expire ) I/O-bound Increase priority one level  CPU-bound jobs move down, I/O-bound jobs move up

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 35 Improving Fairness SJF: optimal, but unfair Increase fairness = give long jobs CPU time  degrades average waiting time Solutions: Each queue – fraction of CPU time Fair iff even distribution of jobs among queues Adjust priority of jobs w/o service Originally done by UNIX Avoids starvation Under load, waiting time suffers

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 36 This Time: Scheduling Algorithms FCFS First-Come, First-Served Round-robin SJF Multilevel Feedback Queues Lottery Scheduling

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 37 Lottery Scheduling Every job gets lottery tickets Each quantum: randomly pick winner On average: CPU time proportional to # of tickets Give most tickets to short-running jobs (approximates SJF) Give every job at least one ticket Degrades gracefully as load changes

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 38 Example: Lottery Scheduling Paying customers: 40%, guests: 60% 2:1 ticket ratio

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 39 Example: Lottery Scheduling Paying customers: 40%, guests: 60% 2:1 ticket ratio

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 40 Example: Lottery Scheduling Paying customers: 40%, guests: 60% 2:1 ticket ratio

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 41 Example: Lottery Scheduling Paying customers: 40%, guests: 60% 2:1 ticket ratio

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 42 Example: Lottery Scheduling Paying customers: 40%, guests: 60% 2:1 ticket ratio

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 43 Example: Lottery Scheduling Paying customers: 40%, guests: 60% 2:1 ticket ratio

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 44 Example: Lottery Scheduling Paying customers: 40%, guests: 60% 2:1 ticket ratio

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 45 Example: Lottery Scheduling /5= 40%

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 46 Example: Lottery Scheduling Probabilistically achieves desired proportions /5= 40% 3/5= 60%

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 47 Summary of Scheduling Algorithms FCFS: unfair, average waiting time poor Round robin: fair, average waiting time poor SJF: unfair, minimizes average waiting time requires accurate prediction Multilevel Feedback Queueing: approximates SJF Lottery scheduling: fair, low average waiting time poor fit to priority

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 48 Next Time Synchronization