Scheduling II. To do. q Proportional-share scheduling q Multilevel-feedback queue q Multiprocessor scheduling q Next Time: Memory management

Similar documents
TCSS 422: OPERATING SYSTEMS

Advanced Operating Systems (CS 202) Scheduling (2)

CPU scheduling. CPU Scheduling

Chapter 6: CPU Scheduling. Basic Concepts. Histogram of CPU-burst Times. CPU Scheduler. Dispatcher. Alternating Sequence of CPU And I/O Bursts

CSC 1600: Chapter 5. CPU Scheduling. Review of Process States

CPU Scheduling. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Scheduling Processes 11/6/16. Processes (refresher) Scheduling Processes The OS has to decide: Scheduler. Scheduling Policies

CPU Scheduling. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

CPU Scheduling. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto

Project 2 solution code

CPU Scheduling. Basic Concepts Scheduling Criteria Scheduling Algorithms. Unix Scheduler

CS510 Operating System Foundations. Jonathan Walpole

CS 143A - Principles of Operating Systems

CPU Scheduling. Jo, Heeseung

Motivation. Types of Scheduling

א א א א א א א א

CPU Scheduling (Chapters 7-11)

SE350: Operating Systems. Lecture 6: Scheduling

CPU Scheduling CPU. Basic Concepts. Basic Concepts. CPU Scheduler. Histogram of CPU-burst Times. Alternating Sequence of CPU and I/O Bursts

CPU Scheduling Minsoo Ryu Real-Time Computing and Communications Lab. Hanyang University

Advanced Types Of Scheduling

CS 153 Design of Operating Systems Winter 2016

CPU SCHEDULING. Scheduling Objectives. Outline. Basic Concepts. Enforcement of fairness in allocating resources to processes

CPU Scheduling. Jo, Heeseung

CPU Scheduling. Chapter 9

Introduction to Operating Systems Prof. Chester Rebeiro Department of Computer Science and Engineering Indian Institute of Technology, Madras

Reading Reference: Textbook: Chapter 7. UNIX PROCESS SCHEDULING Tanzir Ahmed CSCE 313 Fall 2018

CPU Scheduling. Disclaimer: some slides are adopted from book authors and Dr. Kulkarni s slides with permission

Scheduling Algorithms. Jay Kothari CS 370: Operating Systems July 9, 2008

Principles of Operating Systems

CSE 5343/7343 Fall 2006 PROCESS SCHEDULING

CS 111. Operating Systems Peter Reiher

Lecture 11: CPU Scheduling

Scheduling. CSE Computer Systems November 19, 2001

Introduction to Operating Systems. Process Scheduling. John Franco. Dept. of Electrical Engineering and Computing Systems University of Cincinnati

Operating Systems. Scheduling

Uniprocessor Scheduling

Comp 204: Computer Systems and Their Implementation. Lecture 10: Process Scheduling

Stride Scheduling. Robert Grimm New York University

CPU scheduling CPU 1. P k P 3 P 2 P 1 CPU 2. CPU n. The scheduling problem: Which jobs should we assign to which CPU(s)?

Announcements. Program #1. Reading. Is on the web Additional info on elf file format is on the web. Chapter 6. CMSC 412 S02 (lect 5)

CSE 451: Operating Systems Spring Module 8 Scheduling

Lecture Note #4: Task Scheduling (1) EECS 571 Principles of Real-Time Embedded Systems. Kang G. Shin EECS Department University of Michigan

TABLE OF CONTENTS CHAPTER NO. TITLE PAGE NO. ABSTRACT LIST OF TABLES LIST OF FIGURES LIST OF SYMBOLS AND ABBREVIATIONS

Process Scheduling I. COMS W4118 Prof. Kaustubh R. Joshi hdp://

CSC 553 Operating Systems

Scheduling I. Today. Next Time. ! Introduction to scheduling! Classical algorithms. ! Advanced topics on scheduling

Recall: Example of RR with Time Quantum = 20. Round-Robin Discussion

Real-Time Systems. Modeling Real-Time Systems

An operating system executes a variety of programs: Batch system - jobs Time-shared systems - user programs or tasks

Q1. What is Real time system? Explain the basic model of Real time system. (8)

Intro to O/S Scheduling. Intro to O/S Scheduling (continued)

Roadmap. Tevfik Koşar. CSE 421/521 - Operating Systems Fall Lecture - V CPU Scheduling - I. University at Buffalo.

September 30 th, 2015 Prof. John Kubiatowicz

Improvement of Queue Management for Real Time Task in Operating System

Real-Time and Embedded Systems (M) Lecture 4

CS Advanced Operating Systems Structures and Implementation Lecture 10. Scheduling (Con t) Real-Time Scheduling.

Salisu Aliyu Department of Mathematics, Ahmadu Bello University, Zaria, Nigeria

CPU Scheduling: Part I. Operating Systems. Spring CS5212

Roadmap. Tevfik Ko!ar. CSC Operating Systems Spring Lecture - V CPU Scheduling - I. Louisiana State University.

Journal of Global Research in Computer Science

Chapter 9 Uniprocessor Scheduling

FIFO SJF STCF RR. Operating Systems. Minati De. Department of Mathematics, Indian Institute of Technology Delhi, India. Lecture 6: Scheduling

ELC 4438: Embedded System Design Real-Time Scheduling

Operating System 9 UNIPROCESSOR SCHEDULING

Recall: FCFS Scheduling (Cont.) Example continued: Suppose that processes arrive in order: P 2, P 3, P 1 Now, the Gantt chart for the schedule is:

Tasks or processes attempt to control or react to external events occuring in real time RT processes must be able to keep up events

Clock-Driven Scheduling

Improvised Optimum Multilevel Dynamic Round Robin Algorithm for Optimizing CPU Scheduling

A Paper on Modified Round Robin Algorithm

Process Scheduling Course Notes in Operating Systems 1 (OPESYS1) Justin David Pineda

Lecture 3. Questions? Friday, January 14 CS 470 Operating Systems - Lecture 3 1

Example. You manage a web site, that suddenly becomes wildly popular. Performance starts to degrade. Do you?

IJCSC VOLUME 5 NUMBER 2 JULY-SEPT 2014 PP ISSN

Improving Throughput and Utilization in Parallel Machines Through Concurrent Gang

Comparative Analysis of Basic CPU Scheduling Algorithms

CS162 Operating Systems and Systems Programming Lecture 10. Tips for Handling Group Projects Thread Scheduling

Simulation of Process Scheduling Algorithms

Pallab Banerjee, Probal Banerjee, Shweta Sonali Dhal

Review of Round Robin (RR) CPU Scheduling Algorithm on Varying Time Quantum

Lab: Response Time Analysis using FpsCalc Course: Real-Time Systems Period: Autumn 2015

Lecture 6: CPU Scheduling. CMPUT 379, Section A1, Winter 2014 February 5

The Design of SMART: A Scheduler for Multimedia Applications

Periodic task scheduling

Efficient Round Robin Scheduling Algorithm with Dynamic Time Slice

OPERATING SYSTEMS. Systems and Models. CS 3502 Spring Chapter 03

Performance monitors for multiprocessing systems

Delivering High Performance for Financial Models and Risk Analytics

CPU-Inheritance Scheduling

Computer Sciences Department

Implementing a Predictable Real-Time. Multiprocessor Kernel { The Spring Kernel.

Priority-Driven Scheduling of Periodic Tasks. Why Focus on Uniprocessor Scheduling?

SELF OPTIMIZING KERNEL WITH HYBRID SCHEDULING ALGORITHM

Asia Pacific Journal of Engineering Science and Technology

Real Time Scheduling. Real Time Scheduling. Real-Time Scheduling. Scheduling

A COMPARATIVE ANALYSIS OF SCHEDULING ALGORITHMS

Extending Stride Scheduler with System Credit for Implicit Coscheduling

CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017

Motivating Examples of the Power of Analytical Modeling

Transcription:

Scheduling II To do q Proportional-share scheduling q Multilevel-feedback queue q Multiprocessor scheduling q Next Time: Memory management

Scheduling with multiple goals What if you want both good turnaround time and responsiveness? To optimize turnaround time, SJF But you don t know how long a job will run To improve responsiveness, Round Robin Which is terrible for turnaround time different policies for different jobs? 2

Multilevel queue Ready queue partitioned into separate queues Each has its own scheduling algorithm Now we must schedule between queues Fixed priority scheduling starvation? Time slice each queue gets a fraction of CPU time which it can schedule amongst its processes Highest priority System processes Interactive processes Interactive editing processes Lowest priority Batch processes But how to decide where should a job go? Can the scheduler learn this on the fly? 3

Multiple (feedback) queues Rather than assigning processes to queues, move them around based on their behavior Job enters at highest priority If uses entire slice, it moves down (priority reduced) If it gives up CPU before quantum ends, stays in place How MLFQ approximates SJF ssumes any job is short and gives them highest priority If it turns out to be short, it will run quickly and be done Else, it will move to lower queues nd become more batch-like 4

MLFQ v1 Two jobs:, long-running CPU-intensive; B, short-running, interactive Q2 Q1 Q0 Some issues Starvation again if interactive jobs keep arriving... Gaming the scheduler issuing an I/O before quantum is up and the job won t move What if the process changes behavior over time? 5

MLFQ v2 CTSS First MLFQ IBM 7094 had enough memory for 1 process (switch = swap) Priority classes: class i gets 2 i quantas Runs all proc in queue 0; if empty, all in queue 1, ddressing changing behavior what about process with long start but interactive after that? Carriage-return hit promote process to top class on the assumption it will become interactive Problem Easy to game! Keep hitting that CR key! 6

MLFQ v2 ddressing starvation and changing behavior Periodically boost priority; let s say every time period S; move every job to topmost queue Setting S is another problem Preventing gaming Better accounting, instead of forgetting how much of its time-slice a process has used Track time used, independently of how many times it gave up the CPU Once a process has used its allotment, it is demoted to next priority queue 7

Scheduling challenges Context Manage multiplex scarce resources mong concurrently executing clients Servicing request of varying importance Priority scheduling bsolute control, but crude ssignment is often ad-hoc Resource rights don t vary smoothly Unable to control service rates of tasks No modular abstraction 8

Proportional-share scheduling Don t optimize turnaround or response time, ensure all processes get a fair share of CPU Proportional-share scheduling The execution rate of processes is proportional to the relative share that they are allocated Lottery scheduling a modern example Randomized resource allocation Each process gets lottery tickets for resources (CPU time) Scheduling lottery, i.e. randomly pick a ticket Probabilistically fair 9

Lottery scheduling basic run : 75 tickets; B: 15 tickets Hold the lottery, random[0..99], in our case If 0-74, run, else run B 63 85 70 39 76 17 29 41 36 39 10 99 68 83 63 B B B B : 11/5 ~73% C. Waldspurger and W. Weihl, Lottery scheduling: Flexible proportional-share resource management, In Proc. OSDI 1994. 10

Lottery scheduling CPU allocation and response time follow distributions with well-understood properties Lotteries won by process as a binomial distribution Probability of winning is proportional to number of tickets t p = t/t where T is total tickets fter n draws, expected number of wins E[w] = np Lotteries for a first win has a geometric distribution process avg response time is inversely proportional to ticket allocation Other features No starvation Fair with number of tickets varying dynamically Responsive to changes on ticket allocation 11

Lottery scheduling Simple implementation You just need a good random number generator list of processes with their tickets Pick a winner, walk the list adding up tickets until count exceed winner current process is the winning process B C X 100 50 250 Winner: 299 Count: 0 Count: 100 Count: 150 Count: 400 Winning process: C ny easy way to optimize this? 12

Lottery scheduling Interesting features Tickets can help insulate resource management policies of independent modules Tickets as currency, ticket transfer process can distribute its tickets to its children; the system will adjust the tickets appropriately Tickets as first class objects that can be transferred in msgs If is blocked on B, could loans tickets to B Ticket inflation/deflation as an alternative to transfer client can escalate its resource rights by creating more tickets Only among mutually trusting clients 13

Lottery scheduling Interesting features Ticket currencies to isolate trust boundaries currency for tickets within trust boundaries Each currency is backed by tickets denominated in more primitive currencies defining an acyclic graph Effects of inflation can be contained with a base currency, that is conserved, and an exchange rate Compensation tickets If a process consume a fraction of its allocated resource Issue tickets, proportional to unused resource, until next quantum But how do you assign tickets? ssume the user knows (but that s really a non-solution) 14

nd now a short break 15

Multiple-processor scheduling Multiprocessors are everywhere So, how do you benefit from them? First, a typical application can t you will need to rewrite it to run in parallel Then is the problem of how to schedule across multiple CPUs Snapdragon 820 Quad-core 16

Multiple-processor scheduling CPU cache Mem CPU cache Mem CPU cache Issues with multiprocessing caches Caches and locality (temporal and spatial) Consistency, synchronization and affinity Scheduling complexity From 1d to 2d: Which process to run next? è Which process to run and where? re processes related? When re-scheduling a process, what about the data cached? 17

Multiple-processor scheduling CPU 0 D C B CPU 0 CPU 0 Single-queue scheduling / time sharing Reuse known framework; automatic load-balancing Contention for scheduling data Cache affinity? dd some kind of affinity mechanism (e.g., a bitmask of CPUs allowed, like in Linux sched. 2.4 & 2.5) 18

Multiple-processor scheduling C CPU 0 CPU 0 D B CPU 0 Multiple-queue scheduling / space sharing Multiple queue, each with its own algorithm Process comes into a queue (which one?) and is scheduled from there Clearly more scalable less contention for locks But load imbalance Job migration? Push or pull 19

Some other algorithms Real-time Different categories Soft or Hard RT Important or critical? Hard: not on time ~ not at all Scheduling can be static or dynamic Schedulable real-time system RT system may have to respond to periodic (at regular intervals) or aperiodic (unpredictable) events Given a set of m periodic events i each with period P i and requiring C i seconds of CPU, can the load be handle? Schedulable n admission-control policy could reject/accept a new job depending on this 20

Solaris scheduling as an example Solaris is based on Unix System V Release 4 (SVR4) s in all SVR4-based schedulers, two levels Class-independent: dispatching and preempting (mechanisms) Class-dependent: setting priorities (policy) Three scheduling classes or priority-class types Real time priorities 100-159 System priorities 60-99 Time sharing priorities 0-59 When a process is created, it inherits its parent s priority class characteristics i.e., priority class and global priority value Most jobs will be running in the TS class 21

Solaris TS Scheduling Class - MLFQ Jobs begins at priority 29 (range 0-59) Priority is calculated from two proportional values kernel part and user provided part for backward compatibility (nice) Compute-bound jobs filter down to lower priorities Process priority is lowered after it consumes its quantum Schedule less frequently but for longer Interactive jobs move to higher priorities 22

Policy vs. mechanism Separate what is done from how it is done Think of parent process with multiple children Parent may knows relative importance of children (if, for example, each one has a different task) None of the algorithms presented takes the parent process input for scheduling Scheduling algorithm parameterized Mechanism in the kernel Parameters filled in by user processes Policy set by user process Parent controls scheduling w/o doing it 23

Next time We have discussed sharing CPU to improve utilization and turnaround time For that to happen we also need to share memory We ll start with memory organization and basic management techniques (e.g. paging) 24