CPU Scheduling. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

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

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

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

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

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

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

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

Principles of Operating Systems

Lecture 11: CPU Scheduling

Motivation. Types of 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:

Scheduling: Introduction

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

Journal of Global Research in Computer Science

Operating Systems Process Scheduling Prof. Dr. Armin Lehmann

A Paper on Modified Round Robin Algorithm

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

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

Operating System 9 UNIPROCESSOR SCHEDULING

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

LEAST-MEAN DIFFERENCE ROUND ROBIN (LMDRR) CPU SCHEDULING ALGORITHM

Pallab Banerjee, Probal Banerjee, Shweta Sonali Dhal

Advanced Types Of Scheduling

The BEST Desktop Soft Real-Time Scheduler

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

SELF OPTIMIZING KERNEL WITH HYBRID SCHEDULING ALGORITHM

Queue based Job Scheduling algorithm for Cloud computing

Mixed Round Robin Scheduling for Real Time Systems

Efficient Round Robin Scheduling Algorithm with Dynamic Time Slice

Analysis of Adaptive Round Robin Algorithm and Proposed Round Robin Remaining Time Algorithm

A Survey of Resource Scheduling Algorithms in Green Computing

Smarter Round Robin Scheduling Algorithm for Cloud Computing and Big Data

Process Scheduling for John Russo generated Mon Nov 07 13:57:15 EST 2011

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

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

IJRASET: All Rights are Reserved

Job Scheduling in Cluster Computing: A Student Project

A TECHNICAL LOOK INSIDE ASE 15.7 S HYBRID THREADED KERNEL

A note on \The Limited Performance Benets of. Migrating Active Processes for Load Sharing" Allen B. Downey and Mor Harchol-Balter

10/1/2013 BOINC. Volunteer Computing - Scheduling in BOINC 5 BOINC. Challenges of Volunteer Computing. BOINC Challenge: Resource availability

Real-Time Systems. Modeling Real-Time Systems

Clock-Driven Scheduling

Energy-Efficient Scheduling of Interactive Services on Heterogeneous Multicore Processors

Gang Scheduling Performance on a Cluster of Non-Dedicated Workstations

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

Lecture 6: Scheduling. Michael O Boyle Embedded Software

Reference model of real-time systems

Introduction to Real-Time Systems. Note: Slides are adopted from Lui Sha and Marco Caccamo

International Journal of Computer Trends and Technology (IJCTT) volume 10number5 Apr 2014

Introduction to Experimental Design

Power-aware Work Stealing in Homogeneous Multicore Systems

AWS vs. Google Cloud Pricing

Adaptive Power Profiling for Many-Core HPC Architectures

Balancing Power Consumption in Multiprocessor Systems

Effective load balancing for cluster-based servers employing job preemption

Decentralized Preemptive Scheduling Across Heterogeneous Multi-core Grid Resources

Real-Time Scheduling Theory and Ada

Hadoop Fair Scheduler Design Document

DeltaV Control Module Execution

HTCaaS: Leveraging Distributed Supercomputing Infrastructures for Large- Scale Scientific Computing

General Terms Measurement, Performance, Design, Theory. Keywords Dynamic load balancing, Load sharing, Pareto distribution, 1.

5 Metrics You Should Know to Understand Your Engineering Efficiency

An-Najah National University Faculty of Engineering Industrial Engineering Department. System Dynamics. Instructor: Eng.

International Journal of Scientific & Engineering Research, Volume 7, Issue 12, December ISSN

Factors Influencing Job Rejections in Cloud Environment

Production Job Scheduling for Parallel Shared Memory Systems

Best in Service Program Overview

QUANTITATIVE EVALUATION OF JOB AND RESOURCES FOR BETTER SELECTION TO IMPROVE MAKESPAN IN GRID SCHEDULING

Preemptive Scheduling of Multi-Criticality Systems with Varying Degrees of Execution Time Assurance

Scopely Gets the High Scores with Redis Labs

Trace Driven Analytic Modeling for Evaluating Schedulers for Clusters of Computers

Fairness and Efficiency in Web Server Protocols

Operations and Production Management GPO300

Fixed-Priority Preemptive Multiprocessor Scheduling: To Partition or not to Partition

A Contention-Aware Hybrid Evaluator for Schedulers of Big Data Applications in Computer Clusters

On-line Multi-threaded Scheduling

Real-time System Overheads: a Literature Overview

System. Figure 1: An Abstract System. If we observed such an abstract system we might measure the following quantities:

PSBS: Practical Size-Based Scheduling

A Decomposition Approach for the Inventory Routing Problem

Resource Allocation Strategies in a 2-level Hierarchical Grid System

Perspective Study on task scheduling in computational grid

System performance analysis Introduction and motivation

Five trends in Capacity Management

Andrew Triganza Scott ISR 2016

Deferred Assignment Scheduling in Clustered Web Servers

OSPF Link-State Advertisement Throttling

ure Outline edulability tests for fixed-priority systems ctical factors nues from material in lecturee 5, with the same assumption

Modeling the Relative Fitness of Storage

DYNAMIC FULFILLMENT (DF) The Answer To Omni-channel Retailing s Fulfillment Challenges. Who s This For?

Delay Attribution Board Process and Guidance Document 8 Delay Allocation Entering and Leaving the Network Rail network

Job Scheduling for Multi-User MapReduce Clusters

Securing MapReduce Result Integrity via Verification-based Integrity Assurance Framework

OPTIMAL ALLOCATION OF WORK IN A TWO-STEP PRODUCTION PROCESS USING CIRCULATING PALLETS. Arne Thesen

Asymptotic Analysis of Real-Time Queues

Software development activities

OSPF Link-State Advertisement Throttling

The Social Marketers Guide to Managing A Large Facebook Page

Addressing UNIX and NT server performance

The Portable Batch Scheduler and the Maui Scheduler on Linux Clusters*

Transcription:

CPU Scheduling Jinkyu Jeong (jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu SSE3044: Operating Systems, Fall 2017, Jinkyu Jeong (jinkyu@skku.edu)

CPU Scheduling policy deciding which process to run next, given a set of runnable processes Happens frequently, hence should be fast Mechanism How to transition? Ready Scheduled Time slice exhausted Running Policy When to transition? I/O or event completion Blocked I/O or event wait SSE3044: Operating Systems, Fall 2017, Jinkyu Jeong (jinkyu@skku.edu) 2

Basic pproaches Non-preemptive scheduling The scheduler waits for the running process to voluntarily yield the CPU Processes should be cooperative Preemptive scheduling The scheduler can interrupt a process and force a context switch What happens If a process is preempted in the midst of updating the shared data? If a process in a system call is preempted? SSE3044: Operating Systems, Fall 2017, Jinkyu Jeong (jinkyu@skku.edu) 3

Terminologies Workload set of job descriptions e.g. arrival time, run time, etc. Scheduler logic that decides when jobs run Metric Measurement of scheduling quality e.g. turnaround time, response time, fairness, etc. SSE3044: Operating Systems, Fall 2017, Jinkyu Jeong (jinkyu@skku.edu) 4

Workload ssumptions 1. Each job runs for the same amount of time 2. ll jobs arrive at the same time 3. Once started, each job runs to completion 4. ll jobs only use the CPU (no I/O) 5. The run time of each job is known Metric: Turnaround time! "#$%&$'#%( =! *'+,-."/'%! &$$/1&- SSE3044: Operating Systems, Fall 2017, Jinkyu Jeong (jinkyu@skku.edu) 5

FIFO First-Come, First-Served Jobs are scheduled in order that they arrive Real-world scheduling of people in lines e.g. supermarket, bank tellers, McDonalds, etc. Non-preemptive Jobs are treated equally: no starvation Problems Convoy effect verage turnaround time can be large if small jobs wait behind long ones SSE3044: Operating Systems, Fall 2017, Jinkyu Jeong (jinkyu@skku.edu) 6

SJF Shortest Job First Each job has a variable run time (ssumption 1 relaxed) Choose the job with the smallest run time Can prove that SJF shows the optimal turnaround time under our assumptions Non-preemptive Problems Not optimal when jobs arrive at any time Can potentially starve SSE3044: Operating Systems, Fall 2017, Jinkyu Jeong (jinkyu@skku.edu) 7

FIFO vs. SJF FIFO (10), B(10), C(10) (100), B(10), C(10) B C B C 0 20 40 60 80 100 120! "#$%&$'#%( = (+, +., + /,)// =., 0 20 40 60 80 100 120! "#$%&$'#%( = (+,, + ++, + +.,)// = ++, SJF (100), B(10), C(10) (100) B(10), C(10) B C B C 0 20 40 60 80 100 120! "#$%&$'#%( = (+, +., + +.,)// = 2, 0 20 40 60 80 100 120! "#$%&$'#%( = (+,, + 3, + +,,)// = 34. 6 SSE3044: Operating Systems, Fall 2017, Jinkyu Jeong (jinkyu@skku.edu) 8

STCF Shortest Time-to-Completion First Jobs are not available simultaneously (ssumption 2 relaxed) Preemptive version of SJF (ssumption 3 relaxed) If a new job arrives with the run time less than the remaining time of the current job, preempt it (100) B(10), C(10) (100) B(10), C(10) B C B C 0 20 40 60 80 100 120! "#$%&$'#%( = (+,, +., + +,,)/1 =.2. 4 SJF 0 20 40 60 80 100 120! "#$%&$'#%( = (+5, + +, + 5,)/1 = 6, STCF SSE3044: Operating Systems, Fall 2017, Jinkyu Jeong (jinkyu@skku.edu) 9

RR Round Robin Run queue is treated as a circular FIFO queue Each job is given a time slice (or scheduling quantum) Multiple of the timer-interrupt period or the timer tick Too short à higher context switch overhead Too long à less responsive Usually 10 ~ 100ms Runs a job for a time slice and then switches to the next job in the run queue Preemptive No starvation Improved response time à great for time-sharing SSE3044: Operating Systems, Fall 2017, Jinkyu Jeong (jinkyu@skku.edu) 10

SJF vs. RR RR focuses on a new metric: response time! "#$%&'$# =! )*"$+",'!.""*/.0 Typically, RR has higher turnaround time than SJF, but better response time (30), B(30), C(30) (30), B(30), C(30) B C B C B C B C 0 20 40 60 80 100 120! +,"'."&,'1 = (34 + 64 + 74)/3 = 64! "#$%&'$# = (4 + 34 + 64)/3 = 34 SJF 0 20 40 60 80 100 120! +,"'."&,'1 = (:4 + ;4 + 74)/3 = ;4! "#$%&'$# = (4 + <4 + =4)/3 = <4 RR SSE3044: Operating Systems, Fall 2017, Jinkyu Jeong (jinkyu@skku.edu) 11

(Static) Priority Scheduling Each job has a (static) priority cf.) nice(), renice(), setpriority(), getpriority() Choose the job with the highest priority to run next ex.) shortest job in SJF Round-robin or FIFO within the same priority Can be either preemptive or non-preemptive Starvation problem If there is an endless supply of high priority jobs, no low priority job will ever run SSE3044: Operating Systems, Fall 2017, Jinkyu Jeong (jinkyu@skku.edu) 12

Incorporating I/O I/O-aware scheduling ssumption 4 relaxed Overlap computation with I/O Treat each CPU burst as an independent job Example: (interactive) + B (CPU-intensive) CPU burst I/O burst CPU B B B B B Disk 0 20 40 60 80 100 120 STCF 0 20 40 60 80 100 120 I/O-aware STCF SSE3044: Operating Systems, Fall 2017, Jinkyu Jeong (jinkyu@skku.edu) 13

Towards a General CPU Scheduler Goals Optimize turnaround time Minimize response time for interactive jobs Challenge: No a priori knowledge on the workloads The run time of each job is known (ssumption 5) How can the scheduler learn the characteristics of the jobs and make better decisions? Learn from the past to predict the future (as in branch predictors or cache algorithms) SSE3044: Operating Systems, Fall 2017, Jinkyu Jeong (jinkyu@skku.edu) 14

MLFQ Multi-Level Feedback Queue number of distinct queues for each priority level Priority scheduling b/w queues, round-robin in the same queue Rule 1: If Priority() > Priority(B), runs (B doesn t). Rule 2: If Priority() = Priority(B), & B run in RR. Priority is varied based on its observed behavior SSE3044: Operating Systems, Fall 2017, Jinkyu Jeong (jinkyu@skku.edu) 15

Changing Priority Typical workload: a mix of Interactive jobs: short-running, require fast response time CPU-intensive jobs: need a lot of CPU time, don t care about response time ttempt #1: Dynamic Priority Change Rule 3: When a job enters the system, it is placed at the highest priority (the topmost queue). Rule 4a: If a job uses up an entire time slice while running, its priority is reduced (i.e. moves down one queue). Rule 4b: If a job gives up the CPU before the time slice is up, it stays at the same priority level. SSE3044: Operating Systems, Fall 2017, Jinkyu Jeong (jinkyu@skku.edu) 16

Scheduling Under Rules 1-4 Workload : long-running job, B: short-running job, C: interactive job B C Q2 B B terminated Q1 B Q0 0 20 40 60 80 100 120 140 160 180 200 220 SSE3044: Operating Systems, Fall 2017, Jinkyu Jeong (jinkyu@skku.edu) 17

Priority Boost Problems in ttempt #1 Long-running jobs can starve due to too many interactive jobs malicious user can game the scheduler by relinquishing the CPU just before the time slice is expired program may change its behavior over time ttempt #2: Priority Boost Rule 5: fter some time period S, move all the jobs in the system to the topmost queue. SSE3044: Operating Systems, Fall 2017, Jinkyu Jeong (jinkyu@skku.edu) 18

Scheduling Under Rules 1-5 Q2 Without Priority Boost Q1 Q0 starvation 0 20 40 60 80 100 120 140 160 180 200 220 With Priority Boost Q2 Q1 Q0 Boost Boost Boost 0 20 40 60 80 100 120 140 160 180 200 220 SSE3044: Operating Systems, Fall 2017, Jinkyu Jeong (jinkyu@skku.edu) 19

Better ccounting ttempt #3: Revise Rule 4a/4b for better accounting Rule 4: Once a job uses up its time allotment at a given level (regardless of how many times it has given up the CPU), its priority is reduced. Q2 B B B B B B B B B B Q1 B Q0 B B B B 0 20 40 60 80 100 Without precise accounting 0 20 40 60 80 100 With precise accounting SSE3044: Operating Systems, Fall 2017, Jinkyu Jeong (jinkyu@skku.edu) 20

UNIX Scheduler MLFQ Preemptive priority scheduling Time-shared based on time slice Processes dynamically change priority 3~4 classes spanning ~170 priority levels (Solaris 2) Favor interactive processes over CPU-bound processes Use aging: no starvation Increase priority as a function of wait time Decrease priority as a function of CPU time Many ugly heuristics for voo-doo constants SSE3044: Operating Systems, Fall 2017, Jinkyu Jeong (jinkyu@skku.edu) 21