Operating Systems CSE 411 CPU Management Sept. 20 2006 - Lecture 7 Instructor: Bhuvan Urgaonkar.

Slides:



Advertisements
Similar presentations
CPU Scheduling.
Advertisements

CPU Scheduling Tanenbaum Ch 2.4 Silberchatz and Galvin Ch 5.
CH 5. CPU Scheduling Basic Concepts F CPU Scheduling  context switching u CPU switching for another process u saving old PCB and loading.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 5: CPU Scheduling.
Operating Systems CMPSC 473 Processes (contd.) September 09, Lecture 6 Instructor: Sriram Govindan.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 19 Scheduling IV.
Chapter 5 CPU Scheduling. CPU Scheduling Topics: Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling.
CPU Scheduling CS 3100 CPU Scheduling1. Objectives To introduce CPU scheduling, which is the basis for multiprogrammed operating systems To describe various.
Cs238 CPU Scheduling Dr. Alan R. Davis.
Scheduling in Batch Systems
Chapter 6: CPU Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 2, 2005 Chapter 6: CPU Scheduling Basic.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
Cs238 CPU Scheduling Dr. Alan R. Davis. CPU Scheduling The objective of multiprogramming is to have some process running at all times, to maximize CPU.
5: CPU-Scheduling1 Jerry Breecher OPERATING SYSTEMS SCHEDULING.
Operating System Concepts with Java – 7 th Edition, Nov 15, 2006 Silberschatz, Galvin and Gagne ©2007 Chapter 5: CPU Scheduling.
Job scheduling Queue discipline.
Process Concept An operating system executes a variety of programs
Operating System Process Scheduling (Ch 4.2, )
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Lecture 5 Operating Systems.
CSC 360- Instructor: K. Wu CPU Scheduling. CSC 360- Instructor: K. Wu Agenda 1.What is CPU scheduling? 2.CPU burst distribution 3.CPU scheduler and dispatcher.
Silberschatz, Galvin, and Gagne  Applied Operating System Concepts Module 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
CPU Scheduling Introduction to Operating Systems: Module 13.
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.
Chapter 6 Scheduling. Basic concepts Goal is maximum utilization –what does this mean? –cpu pegged at 100% ?? Most programs are I/O bound Thus some other.
Operating Systems Lecture Notes CPU Scheduling Matthew Dailey Some material © Silberschatz, Galvin, and Gagne, 2002.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
CPU Scheduling CSCI 444/544 Operating Systems Fall 2008.
Silberschatz and Galvin  Operating System Concepts Module 5: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor.
Peng Lu. CPU Scheduling 1. Basic Concepts 2. Scheduling Criteria 3. Scheduling Algorithms 4. Multiple-Processor Scheduling 5. Real-Time Scheduling 2.
Operating Systems CSE 411 CPU Management Sept Lecture 9 Instructor: Bhuvan Urgaonkar.
Process A program in execution. But, What does it mean to be “in execution”?
CE Operating Systems Lecture 7 Threads & Introduction to CPU Scheduling.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
Chapter 5: CPU Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 5: CPU Scheduling Basic Concepts Scheduling Criteria.
CMSC 421 Spring 2004 Section 0202 Part II: Process Management Chapter 6 CPU Scheduling.
Chapter 4: Threads. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th edition, Jan 23, 2005 Chapter 4: Threads Overview Multithreading.
Chapter 5: Process Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Basic Concepts Maximum CPU utilization can be obtained.
Chapter 5: CPU Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 5: CPU Scheduling Basic Concepts Scheduling Criteria.
1 11/29/2015 Chapter 6: CPU Scheduling l Basic Concepts l Scheduling Criteria l Scheduling Algorithms l Multiple-Processor Scheduling l Real-Time Scheduling.
Chapter 5: CPU Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 2, 2005 Chapter 5: CPU Scheduling Basic.
Operating Systems CMPSC 473 CPU Scheduling September 07, Lecture 5 Instructor: Bhuvan Urgaonkar.
Silberschatz and Galvin  Operating System Concepts Module 5: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 5 CPU Scheduling Slide 1 Chapter 5 CPU Scheduling.
6.1 CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling Algorithm Evaluation.
Lecture Topics: 11/15 CPU scheduling: –Scheduling goals and algorithms.
Operating Systems CMPSC 473 Processes (contd.) September 01, Lecture 4 Instructor: Bhuvan Urgaonkar.
1 CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling.
1 Uniprocessor Scheduling Chapter 3. 2 Alternating Sequence of CPU And I/O Bursts.
Chapter 4 CPU Scheduling. 2 Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling Algorithm Evaluation.
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.
Basic Concepts Maximum CPU utilization obtained with multiprogramming
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.
Dan C. Marinescu Office: HEC 439 B. Office hours: M, Wd 3 – 4:30 PM.
EEE Embedded Systems Design Process in Operating Systems 서강대학교 전자공학과
Chapter 5a: CPU Scheduling
Chapter 6: CPU Scheduling
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
3: CPU Scheduling Basic Concepts Scheduling Criteria
Chapter 6: CPU Scheduling
CPU scheduling decisions may take place when a process:
Lecture 2 Part 3 CPU Scheduling
Operating System , Fall 2000 EA101 W 9:00-10:00 F 9:00-11:00
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
Presentation transcript:

Operating Systems CSE 411 CPU Management Sept Lecture 7 Instructor: Bhuvan Urgaonkar

Last class –Dispatcher –Context switch, FCFS, SJF, SRPT, RR, Priority, Quantum size –Read on your own: Multi-level (feedback) queue based scheduling Today –More on CPU scheduling

Proportional-Share Schedulers A general class of scheduling algorithms Process P i given a CPU weight w i > 0 The scheduler needs to ensure the following –forall i, j, |T i (t 1, t 2 )/T j (t 1,t 2 ) - w i /w j | ≤ e –Given P i and P j were backlogged during [t 1,t 2 ] Who chooses the weights and how? Application modeling problem: non-trivial –Approaches: analytical, empirical A part of my Ph.D. thesis Many PS schedulers developed in the 90s –E.g., Start-time Fair Queueing (Qlinux UT-Austin/Umass-Amherst)

Lottery Scheduling [Carl Waldspurger, MIT, ~1995] Perhaps the simplest proportional-share scheduler Create lottery tickets equal to the sum of the weights of all processes –What if the weights are non-integral? Draw a lottery ticket and schedule the process that owns that ticket –What if the process is not ready? Draw tickets only for ready processes –Homework 1: Calculate the time/space complexity of the operations Lottery scheduling will involve –Likely question on Exam 1 !!!

Lottery Scheduling Example P1=6P2=9 Schedule P2

Lottery Scheduling Example P1=6P2=9 Schedule P1

Lottery Scheduling Example As t ∞, processes will get their share (unless they were blocked a lot) Problem with Lottery scheduling: Only probabilistic guarantee What does the scheduler have to do –When a new process arrives? –When a process terminates? P1=6P2=9 Schedule P2

Work Conservation Examples of work-conserving schedulers: All schedulers we have studied so far Examples of non-work-conserving schedulers: –DFS, a PS scheduler for multi-processors (Abhishek Chandra, Umass, 2000, now at Univ. of Minnesota) Experiments showed the scheduler had become NWC! Fair Airport to convert into a WC scheme NWC Scheduler WC Scheduler

Reservation-based Schedulers Each process has a pair (x, y) –Divide time into periods of length y each –Guaranteed to get x time units every period Can be Non-work-conserving

Rate Regulation: Leaky Bucket A type of reservation-based scheduling Leaky bucket policing –Rate r i for process P i –CPU cycles over period t  r i * t riri bibi CPU requirement CPU the process gets Max. rate at which the process may progress burst

Rate Regulation: Token Bucket A type of reservation-based scheduling Token bucket policing –Rate r i and burst b i for process P i –CPU cycles over period t  r i * t + b i riri b i tokens CPU requirement burst

Deadline-based Scheduling Can be NWC Several variants NP-hard Real-time systems “Soft” real-time systems –E.g., media servers: 30 MPEG-1 frames/sec –A few violations may be tolerable

An Interesting Problem: An Invitation to do Research on CPU Scheduling Can we achieve the effect of a scheduler that can provide resource guarantees using a priority-based scheduler? You are welcome to talk to me during office hours if you find this interesting or if you have any thoughts on this

Hierarchical Schedulers Variety of schedulers Subsets of processes with different scheduling needs Reservation-based (4, 10) (6, 10) LotteryRound-robin w=1 w=2 UNIX Processes

Scheduler Considerations: Context-Switch Overhead Switching context –User mode to Kernel mode –Save PCB –Process interrupt (e.g, TCP/IP processing) if needed –Run scheduling algorithm –Load registers (e.g., PC) from PCB of chosen process –Flush TLB (will discuss this under memory management) Switching to user mode Jumping to the proper location in the user program to restart that program Context switch time for Pentium/Linux: tens of microsec So how often should the scheduler be invoked?

Scheduler Considerations: Quantum Length The duration for which a CPU-intensive process will run before being scheduled out in favor of another process Different processes may have different quantum lengths –E.g., UNIX: Higher priority => Larger quantum Typically tens of msec in modern systems Small => Context switch overhead high Large => Bad responsiveness => Interactive processes suffer

Scheduler Considerations: CPU Accounting Scheduler maintains CPU usage, last scheduling instant etc. in each PCB Who should be charged for the CPU usage during interrupt processing? –Optional reading: Resource containers (Rice University, OSDI 1999, Gaurav Banga et al. )

Scheduler Considerations: Time and Space Requirements Run time (n processes) –FCFS: O(1) –RR: O(1) –Deadline-based algos: NP-hard variants, poly-time heuristics Update time: Operations done when set of processes changes (new, terminate, block, become ready) Space requirements –Space to store various data structs

Scheduler Evaluation Optimize one or more of response time, waiting time, throughput, fairness, utilization,.. Overheads –Run time (time to pick the next process to schedule) –Update time –Space requirements

Analytical Approaches to Scheduler Evaluation Example 1: Our evaluation of FCFS and SJF Example 2: Queueing Theory –Little’s Law: applies to any scheduling discipline –avg_num_processes_in_system = tput * avg_time_spent_in_system –Queuing theory provides expressions for mean response time for certain scheduling policies (FCFS, PS, LCFS) –Other statistical properties of response time only under restrictive assumptions on arrival process and service time runningwaiting yet to arriveserviced

Discussion: Analytical Approaches Pros: –Intellectually satisfying! –Quick, no code to be written –May provide generally applicable results Cons: –Often over-simplified Hard to model complex scheduling algorithms Lack of info about workloads

Simulation-based Evaluation Write software that mimics the behavior of the scheduler Subject it to realistic workload Observe output and make inferences about performance of scheduler Only need to know the algorithms, no need to do complex math Easier to implement than the actual system

Prototyping Build it!

Analysis, Simulation, and Prototyping Compared Analysis Simulation Prototyping accuracy, programming skills effort, time investment, mathematical skills, generality

Hybrid Approaches Analysis SimulationPrototyping

Threads

What is a Thread? A basic unit of CPU utilization like a process (not necessarily known to the OS though) “Smaller” than a process –Part of a process –Shares code + data + some other OS resources with other threads that belong to the same process

User Threads Thread management done by user-level threads library OS doesn’t know about the existence of these threads Three primary thread libraries: – POSIX Pthreads – Win32 threads – Java threads

Kernel Threads OS sees and manages these threads OS provides system calls to create, terminate, etc. (just like the system calls it provides for processes) Examples –Windows XP/2000 –Solaris –Linux –Tru64 UNIX –Mac OS X

Benefits Responsiveness Resource Sharing Economy Utilization of MP Architectures