Recall … Process states –scheduler transitions (red) Challenges: –Which process should run? –When should processes be preempted? –When are scheduling decisions.

Slides:



Advertisements
Similar presentations
Chapter 9 Uniprocessor Scheduling Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College, Venice,
Advertisements

CPU Scheduling.
Topic : Process Management Lecture By: Rupinder Kaur Lecturer IT, SRS Govt. Polytechnic College for Girls,Ludhiana.
1 Uniprocessor Scheduling Types of scheduling –The aim of processor scheduling is to assign processes to be executed by the processor so as to optimize.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 17 Scheduling III.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Chapter 6a: CPU Scheduling.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 5: CPU Scheduling.
Scheduling Algorithms
Chapter 9 Uniprocessor Scheduling Operating Systems: Internals and Design Principles, 6/E William Stallings Dave Bremer Otago Polytechnic, N.Z. ©2008,
Day 25 Uniprocessor scheduling. Algorithm: Selection function Selection function – which process among ready processes to select. w – time spent in system,
Chapter 3: CPU Scheduling
Operating Systems 1 K. Salah Module 2.1: CPU Scheduling Scheduling Types Scheduling Criteria Scheduling Algorithms Performance Evaluation.
CS 3013 & CS 502 Summer 2006 Scheduling1 The art and science of allocating the CPU and other resources to processes.
Uniprocessor Scheduling Chapter 9. Aim of Scheduling The key to multiprogramming is scheduling Scheduling is done to meet the goals of –Response time.
What we will cover…  CPU Scheduling  Basic Concepts  Scheduling Criteria  Scheduling Algorithms  Evaluations 1-1 Lecture 4.
5: CPU-Scheduling1 Jerry Breecher OPERATING SYSTEMS SCHEDULING.
1 Uniprocessor Scheduling Chapter 9. 2 Aims of Scheduling Assign processes to be executed by the processor(s) Response time Throughput Processor efficiency.
Wk 2 – Scheduling 1 CS502 Spring 2006 Scheduling The art and science of allocating the CPU and other resources to processes.
Job scheduling Queue discipline.
02/11/2004CSCI 315 Operating Systems Design1 CPU Scheduling Algorithms Notice: The slides for this lecture have been largely based on those accompanying.
1 Lecture 10: Uniprocessor Scheduling. 2 CPU Scheduling n The problem: scheduling the usage of a single processor among all the existing processes in.
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.
Uniprocessor 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.
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.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Lecture 5 Operating Systems.
OPERATING SYSTEMS CPU SCHEDULING.  Introduction to CPU scheduling Introduction to CPU scheduling  Dispatcher Dispatcher  Terms used in CPU scheduling.
Chapter 9 Uniprocessor Scheduling Spring, 2011 School of Computer Science & Engineering Chung-Ang University.
Chapter 6 CPU SCHEDULING.
More Scheduling cs550 Operating Systems David Monismith.
1 Scheduling Processes. 2 Processes Each process has state, that includes its text and data, procedure call stack, etc. This state resides in memory.
Scheduling. Alternating Sequence of CPU And I/O Bursts.
Uniprocessor Scheduling Chapter 9. Aim of Scheduling To improve: Response time: time it takes a system to react to a given input Turnaround Time (TAT)
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.
CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Thread Scheduling Multiple-Processor Scheduling Operating Systems Examples Algorithm.
Lecture 7: Scheduling preemptive/non-preemptive scheduler CPU bursts
1 Uniprocessor Scheduling Chapter 9. 2 Aim of Scheduling Response time Throughput Processor efficiency.
Uniprocessor Scheduling
Operating System 9 UNIPROCESSOR SCHEDULING. TYPES OF PROCESSOR SCHEDULING.
ITFN 2601 Introduction to Operating Systems Lecture 4 Scheduling.
Uniprocessor Scheduling Chapter 9. Aim of Scheduling Assign processes to be executed by the processor or processors: –Response time –Throughput –Processor.
Lecture Topics: 11/15 CPU scheduling: –Scheduling goals and algorithms.
1 CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling.
Introduction to Operating System Created by : Zahid Javed CPU Scheduling Fifth Lecture.
Operating Systems Scheduling. Scheduling Short term scheduler (CPU Scheduler) –Whenever the CPU becomes idle, a process must be selected for execution.
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 CS Introduction to Operating Systems.
CPU scheduling.  Single Process  one process at a time  Maximum CPU utilization obtained with multiprogramming  CPU idle :waiting time is wasted 2.
Lecturer 5: Process Scheduling Process Scheduling  Criteria & Objectives Types of Scheduling  Long term  Medium term  Short term CPU Scheduling Algorithms.
 In a single-processor system, only one process can run at a time; any others must wait until the CPU is free and can be rescheduled.  The objective.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 5: CPU Scheduling.
Chapter 5: CPU Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 5: CPU Scheduling Basic Concepts Scheduling Criteria.
1 Chapter 5: CPU Scheduling. 2 Basic Concepts Scheduling Criteria Scheduling Algorithms.
CPU SCHEDULING.
Chapter 5a: CPU Scheduling
Uniprocessor Scheduling
Uniprocessor Scheduling
Chapter 6: CPU Scheduling
Chapter 5: CPU Scheduling
Chapter 9 Uniprocessor Scheduling
CPU SCHEDULING.
Process Scheduling Decide which process should run and for how long
Uniprocessor Scheduling
Presentation transcript:

Recall … Process states –scheduler transitions (red) Challenges: –Which process should run? –When should processes be preempted? –When are scheduling decisions made? ready running blocked block unblock preempt schedule terminate

Today: Process Scheduling Algorithms Objective: a high performance system –Efficiency: Maximize CPU time spent executing user programs. Recall that context switch is expensive. –on the order of 10 4 instructions But not at the expense of…. –Responsiveness What do I mean by responsiveness? –Average user happiest? –Long computations complete in reasonable time? Several approaches will be described.

Process Scheduling by Objective Eric Freudenthal

(almost) Universal scheduler algorithm Run the process that results in greatest value (priority) –Computed priority represents some scheduling objective –Priority can only be computed from available information Assigned process importance (if available) How long in ready queue, how long running Characteristics of process –i/o bound, resources held, how long since submission When does scheduler algorithm execute? –Whenever running process blocks –Maybe at other times too: Maybe: Whenever a process becomes ready. Maybe: Whenever quantum expires. –Is quantum fixed? If not, how is it computed? Challenge: mapping objectives to priorities

Name Game Warning Play at your own risk. The algorithms described today are known by multiple names. I use names that appear in Tannenbaum. Class notes include a table titled “the name game” listing the algorithms’ names in multiple text books.

Objective: Fairness (first attempt): First-Come First-Served Process that has been “ready” the longest has highest priority. –Head item if “ready queue” is a FIFO No preemption –Processes execute until they terminate or block. Feature: Minimizes sharing of cache(s) Problem: A process can “hog” the processor, starving others.

Objective: Fairness Round Robin First-Come First-Served with Preemption Preempt processes that ‘hog’ the processor –How to pick quantum Extreme fairness: q = 1 instruction –Cost of context switching consumes >99.9% of CPU Reasonable q = 1-10ms = 0.001s –Modern processors execute Approx 1G i/s –1M instructions = (approx) 1ms

Variants on Round Robin Prioritization by adjusting the quantum –Is it “fairer” to provide more execution time to some processes: Those holding resources that effectively delay others Those pay more? Maybe: increase q for these “higher priority” processes. All processes have quantum = ∞ –No preemption, therefore “First come first served”

Theoretical digression: Processor Sharing This is a theoretical model –Each of n ready processes proceeds at rate 1/n. –For example, if 3 processes are ready, each executes 1/3 of an instruction in 1 cycle. –Useful for mathematical analysis since it models a process’ effective rate of execution as a fraction. As if RR could have tiny quantum –(say i)

Objective: important processes proceed most quickly Priority Scheduling Processes assigned rank at entry. –Perhaps users pay more for higher rank? Process with highest “rank” always runs. –Round-robin if multiple at highest rank Preemption: –Run scheduler every time a process becomes ready. preempt if higher rank process is ready Two challenges: starvation and priority inversion. (next two slides)

Priority challenge 1: Starvation Problem: –Low priority process may never run Solution: Priority aging –Temporarily raise rank of ready processes at some rate. –Effect: processes with lower rank wait longer to run if higher priority processes are ready. –When is aging computation performed? When processes become ready. When quantum expires

Priority Challenge 2: “Priority inversion” possible Low rank process holds resource needed by high rank process. –Example A: rank = 3, needs tape drive (blocked) B. rank = 2, ready C: rank = 1, has tape drive, ready Problem: –B has higher rank than C –So B will execute, and A will be delayed. Effectively inverts priority!!!! Solution: temporary “promote” C to A’s priority: –Promotion rule: All low rank processes {C} holding resource req’d by some higher rank process A, are temporarily promoted to A’s rank.

Objective: giving older jobs advantage: Selfish Round-Robin Round-robin among the ‘in’ group of accepted processes. Really just a computed-rank algorithm. Every process π has increasing rank R π –R π initially zero Define acceptance threshold T = max(R π ) If R π = T, π’s state is accepted –Accepted processes scheduled using RR –R π increases after arrival: If R π < T, increase V π at rate “A” If R π = T, increase V π at rate “B” –If B ≥ A, then monoprogrammed –If B = 0, then RR (since T = 0) –If A > B > 0, then new processes excluded for a while Rate A

Rank = -(remaining execution time) Minimizes waiting time –Consider two jobs A > B that never block If A run before B, total waiting time = A + (A+B) If B run before A, total waiting time = B + (A+B) True for more than two processes too. Challenge: prior knowledge of execution time. –Reasonable variant: prioritize by burst length, and use past behavior to predict the future. Challenge: Starvation of long jobs. –“Solution”: Priority aging Also: Preemptive version –PSJF – preemptive shortest job first –Shortest job remains shortest if no shorter job becomes ready Objective: Minimize waiting Shortest Job First

Fairness revisited: Prioritize disadvantaged processes. Highest Penalty Ratio Next Define “Penalty Ratio” –T = wall clock time since arrival –t = execution time –Penalty ratio r = T/t, highest r has priority Represents how much process’s progress has been penalized due to i/o and multiprogramming. –Nuisance: ratio undefined until run (fudge this) Preemptive variant: –Re-evaluate penalty ratios when processes unblock –Set timer to expire when current process no longer highest priority –Be careful not to allow timer period to approach zero!

Objective: Favor Interactive Processes Multi-Level Queues Multiple classes of processes –Class 3: Interactive –Class 2: Batch –Class 1: Cycle-soaker (low priority background). Can be implemented using 3 queues –Policy among queues For example: Run process with highest priority in highest non-empty queue. –Differing queues can implement different policies For example, queue 1 could be FCFS

Favoring Interactive Processes with automatic detection. Multi-level Feedback Queues An interactive process that doesn’t block for a long time is demoted to ‘background’ and therefore treated differently (given lower priority…). A background process that blocks frequently can be promoted to interactive. Implemented using multilevel queues. –processes migrate between queues based on their recent behavior.

Questions? First Come First Served (no quantum) Round Robin (quantum) –Selfish Round Robin (snobish RR, latecomers wait) –Processor Sharing (theoretical RR) Priority Scheduling (highest priority runs) –Remember priority inversion! (preemptive) Shortest Job First Highest “Penalty Ratio” Next (greatest T/t) Multi-level Queues (distinct classes of job) –Multi-level Feedback Queues (auto classify)