CompSci 143A1 5. Process and thread scheduling 5.1 Organization of Schedulers – Embedded and Autonomous Schedulers – Priority Scheduling 5.2 Scheduling.

Slides:



Advertisements
Similar presentations
CH 5. CPU Scheduling Basic Concepts F CPU Scheduling  context switching u CPU switching for another process u saving old PCB and loading.
Advertisements

Operating Systems Principles Process Management and Coordination Lecture 5: Process and Thread Scheduling 主講人:虞台文.
Operating Systems1 5. Process and thread scheduling 5.1 Organization of Schedulers – Embedded and Autonomous Schedulers 5.2 Scheduling Methods – A Framework.
CHAPTER 5 Organization of Schedulers Scheduling Methods Priority Inversion Multiprocessor and Distributed Scheduling Process and Thread Scheduling.
Operating Systems Chapter 6
Chap 5 Process Scheduling. Basic Concepts Maximum CPU utilization obtained with multiprogramming CPU–I/O Burst Cycle – Process execution consists of a.
Chapter 5 CPU Scheduling. CPU Scheduling Topics: Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling.
Operating Systems CPU Scheduling. Agenda for Today What is Scheduler and its types Short-term scheduler Dispatcher Reasons for invoking scheduler Optimization.
CS 311 – Lecture 23 Outline Kernel – Process subsystem Process scheduling Scheduling algorithms User mode and kernel mode Lecture 231CS Operating.
Scheduling in Batch Systems
CS 3013 & CS 502 Summer 2006 Scheduling1 The art and science of allocating the CPU and other resources to processes.
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.
Chapter 5-CPU Scheduling
Wk 2 – Scheduling 1 CS502 Spring 2006 Scheduling The art and science of allocating the CPU and other resources to processes.
Chapter 5: CPU Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 2, 2005 Basic Concepts Maximum CPU utilization.
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.
CS212: OPERATING SYSTEM Lecture 3: Process Scheduling 1.
More Scheduling cs550 Operating Systems David Monismith.
Silberschatz and Galvin  Operating System Concepts Module 5: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor.
CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Thread Scheduling Multiple-Processor Scheduling Operating Systems Examples Algorithm.
ICS Process and thread scheduling 5.1 Organization of Schedulers – Embedded and Autonomous Schedulers – Priority Scheduling 5.2 Scheduling Methods.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
Lecture 7: Scheduling preemptive/non-preemptive scheduler CPU bursts
Chapter 5: CPU Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 5: CPU Scheduling Basic Concepts Scheduling Criteria.
Chapter 5: Process Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Basic Concepts Maximum CPU utilization can be obtained.
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.
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.
Processor Scheduling Hank Levy. 22/4/2016 Goals for Multiprogramming In a multiprogramming system, we try to increase utilization and thruput by overlapping.
1 CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling.
Process Scheduling Schedulers and Scheduling Methods.
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.
1 Module 5: Scheduling CPU Scheduling Scheduling Algorithms Reading: Chapter
Basic Concepts Maximum CPU utilization obtained with multiprogramming
1 Lecture 5: CPU Scheduling Operating System Fall 2006.
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.
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.
EEE Embedded Systems Design Process in Operating Systems 서강대학교 전자공학과
Chapter 5a: CPU Scheduling
CPU Scheduling.
Chapter 6: CPU Scheduling
Chapter 6: CPU Scheduling
CPU Scheduling G.Anuradha
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
Chapter 5: CPU Scheduling
Operating System Concepts
3: CPU Scheduling Basic Concepts Scheduling Criteria
Chapter5: CPU Scheduling
Chapter 5: CPU Scheduling
Chapter 6: CPU Scheduling
Outline Scheduling algorithms Multi-processor scheduling
Chapter 5: CPU Scheduling
Processor Scheduling Hank Levy 1.
Operating System , Fall 2000 EA101 W 9:00-10:00 F 9:00-11:00
Shortest-Job-First (SJR) Scheduling
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
Chapter 6: CPU Scheduling
CPU Scheduling: Basic Concepts
Module 5: CPU Scheduling
Presentation transcript:

CompSci 143A1 5. Process and thread scheduling 5.1 Organization of Schedulers – Embedded and Autonomous Schedulers – Priority Scheduling 5.2 Scheduling Methods – A Framework for Scheduling – Common Scheduling Algorithms – Comparison of Methods 5.3 Priority Inversion 5.4 Multiprocessor and Distributed Scheduling Spring, 2013

CompSci 143A2 Process and Thread Scheduling Process scheduling –Long term scheduling –Move process to Ready List (RL) after creation (When and in which order?) Dispatching –Short term scheduling –Select process from Ready List to run We use the term scheduling to refer to both Spring, 2013

CompSci 143A3 Organization of Schedulers Embedded –Called as function at end of kernel call –Runs as part of calling process Autonomous –Separate process –May have dedicated CPU on a multiprocessor –On single-processor, run at every quantum: scheduler and other processes alternate Figure 5-1 Spring, 2013

CompSci 143A4 Priority Scheduling Priority function returns numerical value P for process p: P = Priority(p) –Static priority: unchanged for lifetime of p –Dynamic priority: changes at runtime Priority divides processes into levels –implemented as multi-level Run List –p at RL[i] run before q at RL[j] if i>j –p, q at same level are ordered by other criteria Spring, 2013

CompSci 143A5 An Embedded Scheduler Scheduler() { do { Find highest priority process p with p.status == ready_a; Find a free cpu; if (cpu != NIL) Allocate_CPU(p,cpu); } while (cpu != NIL); do { Find highest priority process p with p.status == ready_a; Find lowest priority process q with p.status == running; if (Priority(p) > Priority(q)) Preempt(p,q); } while (Priority(p) > Priority(q)); if (self->Status.Type!=’running’) Preempt(p,self); } Spring, 2013

CompSci 143A6 Scheduling Methods When is scheduler invoked? –Decision mode Preemptive: scheduler called periodically (quantum-oriented) or when system state changes Nonpreemptive: scheduler called when process terminates or blocks How does it select highest priority process? –Priority function: P = Priority(p) Some common choices on next few slides –Arbitration rule for breaking ties Random Chronological (First In First Out = FIFO) Cyclic (Round Robin = RR) Spring, 2013

CompSci 143A7 Priority function Parameters Possible parameters: –Attained service time (a) –Real time in system (r) –Total service time (t) –Period (d) –Deadline (explicit or implied by period) –External priority (e) –Memory requirements (mostly for batch) –System load (not process-specific) Spring, 2013

CompSci 143A8 Some Priority functions First in/First out (FIFO) Shortest Job First (SJF) Shortest Remaining Time (SRT) Round Robin (RR) Multi-Level (ML) Spring, 2013

CompSci 143A9 Scheduling algorithms Name, Decision mode, Priority, Arbitration FIFO: nonpreemptive P = r random SJF: nonpreemptive P = –t chronological/random SRT: preemptive P = –(t–a) chronological/random RR: preemptive P = 0 cyclic ML: preemptive P = e cyclic nonpreemptive P = e chronological n fixed priority levels level P is serviced when n through P+1 empty Spring, 2013

CompSci 143A10 MLF (Multilevel Feedback) Like ML, but priority changes dynamically E very process enters at highest level n Each level P prescribes maximum time t P t P increases as P decreases Typically: t n = T (a constant) t P = 2  t P+1 Figure 5-3 Spring, 2013

CompSci 143A11 Scheduling algorithms MLF priority function: Find P = n–i for given a: priority attained time na<T n–1 a<T+2T n–2 a<T+2T+4T... n–i a<(2 i+1 –1)T Find smallest i such that a<(2 i+1 –1)T: Solve for i: i =  log 2 (a/T+1)  P = n–i = n–  log 2 (a/T+1)  Spring, 2013

CompSci 143A12 Scheduling Algorithms Rate Monotonic (RM): –Intended for periodic (real-time) processes –Preemptive –Highest priority: shortest period: P = –d Earliest Deadline First (EDF): –Intended for periodic (real-time) processes –Preemptive –Highest priority: shortest time to next deadline r  d number of completed periods r % d time in current period d – r % d time remaining in current period P = –(d – r % d) priority function Spring, 2013

CompSci 143A13 Comparison of Methods FIFO, SJF, SRT: Primarily for batch systems –FIFO simplest –SJF & SRT have better average turnaround times: (r1+r2+…+rn)/n Average turnaround times: FIFO: ((0+5) + (3+2))/2 = 5.0 SRT: ((2+5) + (0+2))/2 = 4.5 Figure 5-2 Spring, 2013

CompSci 143A14 Comparison of Methods Time-sharing systems –Response time is critical –RR or MLF with RR within each queue are suitable –Choice of quantum determines overhead When q  , RR approaches FIFO When q  0, context switch overhead  100% When q is much greater than context switch overhead, n processes run concurrently at 1/n CPU speed Spring, 2013

CompSci 143A15 Comparison of Methods Real-time systems –Feasible: All deadlines are met –CPU utilization is defined as: U=∑ t i /d i –If schedule is feasible, U  1 –EDF always yields feasible schedule provided U  1. –RM yields feasible schedule if U is not too big (no more than approximately 0.7). Otherwise, it may fail. Spring, 2013

CompSci 143A16 Example where RM fails Process p1 has service time 1.5, period 4 Process p2 has service time 3, period 5 U=(1.5/4) +3/5=.975 < 1 RM fails Figure 5-9 Spring, 2013

CompSci 143A17 Priority Inversion Problem Assume priority order p1>p2>p3 p3 enters CS; p2 preempts p3; p1 preempts p2; p1 blocks on CS Effect: process p2, unrelated to p1 and of lower priority, may delay p1 indefinitely. Note: problem is not simply that p1 blocks. This is unavoidable. The problem is that p1 is waiting on p2. Problem would not occur if p3 in CS had priority greater than p2 Figure 5-10 Spring, 2013

CompSci 143A18 Priority Inversion Problem Naïve “solution”: Always run CS at priority of highest process that shares the CS. Problem: p1 cannot interrupt a lower-priority process inside its CS even if p1 is not trying to enter its CS. This is a different form of priority inversion. Better solution: “Dynamic Priority Inheritance”… Spring, 2013

CompSci 143A19 Priority Inversion Problem Dynamic Priority Inheritance: When p3 is in its CS and p1 attempts to enter its CS… –p3 inherits p1’s (higher) priority for the duration of CS Figure 5-11 Spring, 2013

CompSci 143A20 Multiprocessor and Distributed Scheduling Two Principle approaches –Single Scheduler All processors are in the same resource pool Any process can be allocated to any processor –Multiple Schedulers Processors are divided into sets of separately schedule machines, each with its own scheduler Each process is permanently preallocated to a particular group Useful when different processors have different characteristics and functions Key problem: load balancing –Evenly distributing load over multiple machines Spring, 2013

History Originally developed by Steve Franklin Modified by Michael Dillencourt, Summer, 2007 Modified by Michael Dillencourt, Spring, 2009 CompSci 143A21Spring, 2013