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

Similar documents
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.

Principles of Operating Systems

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

Motivation. Types of Scheduling

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

Project 2 solution code

Lecture 11: CPU Scheduling

CS 153 Design of Operating Systems Winter 2016

Uniprocessor Scheduling

Operating System 9 UNIPROCESSOR SCHEDULING

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

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

CPU Scheduling. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

CPU Scheduling. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

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:

Operating Systems Process Scheduling Prof. Dr. Armin Lehmann

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

Journal of Global Research in Computer Science

A Paper on Modified Round Robin Algorithm

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

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

Advanced Types Of Scheduling

A COMPARATIVE ANALYSIS OF SCHEDULING ALGORITHMS

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

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

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

ENGG4420 CHAPTER 4 LECTURE 3 GENERALIZED TASK SCHEDULER

Pallab Banerjee, Probal Banerjee, Shweta Sonali Dhal

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

Scheduling: Introduction

GENERALIZED TASK SCHEDULER

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

Efficient Round Robin Scheduling Algorithm with Dynamic Time Slice

SELF OPTIMIZING KERNEL WITH HYBRID SCHEDULING ALGORITHM

DEADLINE MONOTONIC ALGORITHM (DMA)

Mixed Round Robin Scheduling for Real Time Systems

Queue based Job Scheduling algorithm for Cloud computing

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

Smarter Round Robin Scheduling Algorithm for Cloud Computing and Big Data

Job Scheduling in Cluster Computing: A Student Project

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

CS 318 Principles of Operating Systems

3. Scheduling issues. Common approaches /2. Common approaches /1. Common approaches / /17 UniPD / T. Vardanega 06/03/2017

SCHEDULING AND CONTROLLING PRODUCTION ACTIVITIES

Clock-Driven Scheduling

Lecture 6: Scheduling. Michael O Boyle Embedded Software

Comparative Study of Parallel Scheduling Algorithm for Parallel Job

Real-Time and Embedded Systems (M) Lecture 4

CHAPTER 4 CONTENT October :10 PM

Stride Scheduling. Robert Grimm New York University

The BEST Desktop Soft Real-Time Scheduler

Real-Time Scheduling Theory and Ada

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

Motivating Examples of the Power of Analytical Modeling

Gang Scheduling Performance on a Cluster of Non-Dedicated Workstations

IJRASET: All Rights are Reserved

A Survey of Resource Scheduling Algorithms in Green Computing

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

Limited-preemptive Earliest Deadline First Scheduling of Real-time Tasks on Multiprocessors

Hadoop Fair Scheduler Design Document

Node Allocation In Grid Computing Using Optimal Resouce Constraint (ORC) Scheduling

Dependency-aware and Resourceefficient Scheduling for Heterogeneous Jobs in Clouds

Real-Time Systems. Modeling Real-Time Systems

Common Tool for Intelligent Scheduling / Critical Chain Project Management for US Navy & Contractor Shipyards

A TECHNICAL LOOK INSIDE ASE 15.7 S HYBRID THREADED KERNEL

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

EPOCH TASK SCHEDULING IN DISTRIBUTED SERVER SYSTEMS

Technical Report CMU/SEI-89-TR-14 ESD-TR-89-; 022. Carnegie-Mellon University. Software Engineering Institute. Real-Time Scheduling Theory

Energy-Efficient Scheduling of Interactive Services on Heterogeneous Multicore Processors

Comparative Analysis of Scheduling Algorithms of Cloudsim in Cloud Computing

A COMPARATIVE ANALYSIS OF SCHEDULING POLICIES IN A DISTRIBUTED SYSTEM USING SIMULATION

LOADING AND SEQUENCING JOBS WITH A FASTEST MACHINE AMONG OTHERS

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

Analysis of SRPT Scheduling: Investigating Unfairness

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

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

Application the Queuing Theory in the Warehouse Optimization Jaroslav Masek, Juraj Camaj, Eva Nedeliakova

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

Reference model of real-time systems

Balancing Power Consumption in Multiprocessor Systems

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

Chapter C Waiting Lines

Resource Allocation Strategies in a 2-level Hierarchical Grid System

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

EFFECT OF CROSS OVER OPERATOR IN GENETIC ALGORITHMS ON ANTICIPATORY SCHEDULING

Hierarchical Job Scheduling for Clusters of Workstations

Bias Scheduling in Heterogeneous Multicore Architectures. David Koufaty Dheeraj Reddy Scott Hahn

Shared Memory Parallelism in Ada: Load Balancing by Work Stealing.

RESOURCE MANAGEMENT IN CLUSTER COMPUTING PLATFORMS FOR LARGE SCALE DATA PROCESSING

Optimized Virtual Resource Deployment using CloudSim

Classifying Scheduling Policies with Respect to Unfairness in an M/GI/1

On the Comparison of CPLEX-Computed Job Schedules with the Self-Tuning dynp Job Scheduler

Decentralized Preemptive Scheduling Across Heterogeneous Multi-core Grid Resources

z/vm Capacity Planning Overview

Limited Preemptive Real-time Scheduling on Multiprocessors. Abhilash Thekkilakattil

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

Operations and Supply Chain Management Prof. G. Srinivasan Department of Management Studies Indian Institute of Technology, Madras

Integrated Scheduling: The Best of Both Worlds

Transcription:

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

OS Queuing Model Enter Ready queue CPU Exit Disk Queue Network Queue Printer Queue Processes enter and leave the system CPU Scheduling Each process in the pool of ready processes is ready to run. Which one to pick to run next? CPU scheduling - Selecting a new process to run from the Ready queue 2

Types of Scheduling Preemptive scheduling - Running process may be interrupted and moved to the Ready queue Non-preemptive scheduling: - once a process is in Running state, it continues to execute until it terminates or blocks for I/O When Does a Scheduler Take Decisions? When a process: 1. Switches from running to waiting state. 2. Switches from running to ready state. 3. Switches from waiting to ready. 4. Terminates. Scheduling under 1 and 4: - Non-preemptive scheduling Scheduling under 2 and 3: - Preemptive scheduling 3

CPU-bound vs. I/O bound Processes Alternating CPU and I/O Bursts 4

The CPU-I/O Burst Cycle Maximum CPU utilization obtained with multiprogramming. CPU-I/O Burst Cycle - Process execution consists of a cycle of CPU execution and I/O wait. Each cycle consists of a CPU burst followed by a (usually longer) I/O burst. A process terminates on a CPU burst. Basic Concepts Burst/Service time = total processor time needed in one CPU-I/O burst cycle. Jobs with long CPU burst time are CPU-bound jobs and are also referred to as long jobs. Jobs with short CPU burst time are I/O-bound jobs and are also referred to as short jobs. CPU-bound processes have longer CPU bursts than I/O-bound processes. 5

CPU Bound vs. I/O Bound Uniprocessor Scheduling We concentrate on the problem of scheduling the usage of a single processor among all the existing ready processes in the system. What goals are we trying to achieve? 6

Scheduling Criteria CPU utilization keeping CPU as busy as possible. Throughput number of processes that complete their execution per time unit. Response time amount of time it takes from when a request was submitted until the first response is produced (for time-sharing environment). Turnaround time amount of time to execute a particular process from start to end. Waiting time amount of time a process has been waiting in the ready queue. Optimization Criteria Maximize - CPU utilization - Throughput Minimize - Response time - Turnaround time - Waiting time Problem: mutually exclusive objectives - No one best way 7

Scheduling Algorithms FCFS RR SJF / SRTF Priority Scheduling Algorithms Next we take a look at four scheduling algorithms and their amusing behavior 1. First Come First Served FCFS 2. Round Robin RR 3. Shortest Job First SJF, SRTF 4. Multi-Level Feedback (Priority) Scheduling very ad hoc. Try and See 8

FCFS Scheduling Example Example: Process Burst Time P 1 100 P 2 2 P 3! 1! Suppose that the processes get created in the order: P 1, P 2, P 3! The Gantt Chart for the schedule is: P 1! P 2! P 3! 0! 100! 102! 103! Waiting time for P 1 = 0; P 2 = 100; P 3 = 102 Average waiting time: (0 + 100 + 102)/3 ~ 67 Average turnaround time: (100+102+103)/3 ~ 102 17 First Come First Served (FCFS or FIFO) Simplest scheduling algorithm: - Run processes in the order in which they arrive - Non-preemptive - Append process at the back of the Waiting queue when blocks on I/O - Append process at the back of the Ready queue when unblocks from I/O Advantage: simple Disadvantages:??? 9

A Twist on the FCFS Example Suppose that the processes arrive in the order P 2 (2), P 3 (1), P 1 (100) The Gantt Chart for the schedule is: Waiting time for P 1 = 3; P 2 = 0 ; P 3 = 2! Average waiting time: (3 + 0 + 2)/3 ~ 2 Average turnaround time: (2+3+103)/3 ~ 36 Much better than previous case 0! P 2! P 3! P 1! 2! 3! 103! 19 FCFS Disadvantage Short processes may be stuck behind long processes (Convoy effect) 10

Round Robin (RR) Solution to job monopolizing CPU? Interrupt it. - Run process for some time quantum (time slice), usually 10-100 ms - When time is, move it to the back of the ready queue - Timer interrupts occur every quantum to schedule next process - Most systems do some flavor of this Advantages: - Fair allocation of CPU across jobs - Low average waiting time when job lengths vary: 1 2 3 4 5 103 P 1 P 2 P 3 P 1 P 2 P 1 - What is the average waiting / turnaround time? A Twist on the RR Example What if the processes have similar sizes? Assume 2 processes of 24 time units each: 1 2 3 4 5 6 7 47 48 P 1 P 2 P 1 P 2 P 1 P 2 P 1 P 1 P 2 - What is the average missed time? - What is the average completion time? - How does it compare to FCFS for the same two processes? 11

Same RR Example with Time Slice = 4 Two processes of 24 time units each, time slice = 8 8 16 24 32 40 48 P 1 P 2 P 1 P 2 P 1 P 2 - What is the average waiting time? - What is the average turnaround time? - How does it compare to FCFS for the same two processes? Main interesting thing is the length of the time slice Round Robin s BIG Disadvantage Performance depends on the sizes of processes and the length of the time slice 12

RR Time Slice Tradeoffs Scheduling involves context switching Timeslice too high - you get FCFS Timeslice too low - most of the time spent on context switching Running Running Job 1 Job 2 Blocked Save context. Load context Save context. Load context Blocked Running Blocked Shortest-Job-First (SJF) Scheduling Use this information to schedule the process with the shortest time. Requires explicit information about the service-time requirements for each process. Nonpreemptive - Once CPU is given to a process, it cannot be preempted until it completes its CPU burst. Preemptive - If another process arrives with a total CPU time requirement less than the remaining CPU time required by the running process preempt! This scheme is know as the Shortest-Remaining-Time-First (SRTF) 13

Example of non-preemptive SJF 3 processes, P 1 (24), P 2 (3), P 3 (3) 3 6 30 P 2 P 3 P 1 - Average turnaround= (3+6+30) / 3 = 13 (compare with 27 for FCFS) Provably optimal - Moving shorter process before longer process improves waiting time of short process more than harms waiting time for long process Example of non-preemptive SJF (2) Process Arrival Time Burst Time P 1 0 7 P 2!2 4 P 3 4 1 P 4 5 4 SJF (non-preemptive) P 1! P 3! P 2! P 4! 0! 3! 7! 8! 12! 16! Average waiting time = (0 + 6 + 3 + 7)/4 = 4 Average completion time =?! 28 14

Example of Preemptive SJF (SRTF) SRTF = Shortest Remaining Time First Process Arrival Time Burst Time P 1 0 7 P 2!2 4 P 3 4 1 P 4 5 4 SRTF (preemptive) 0! P 1! P 2! P 3! P 2! P 4! P 1! 2! 4! 5! 7! 11! 16! Average waiting time = (9 + 1 + 0 +2)/4 = 3 Average completion time =?! 29 SRTF is Optimal but Unfair Gives minimum average missed time However: - Long jobs may starve if too many short jobs 15

Determining Length of Next CPU Burst Can be done by using the length of previous CPU bursts, using exponential averaging: 1. t n = actual length of n th CPU burst 2. e n+1 = expected value for the next CPU burst 3. α, 0 α 1 4. Define: e n+1 = α t n + ( 1 α) e n Examples of Exponential Averaging How to set α in α = 0 e n+1 = α t n + ( 1 α) e n - e n+1 = e n - Recent history does not count α = 1 - e n+1 = t n - Only the actual last CPU burst counts α = 0.5 - balancing past and recent history 16

Idea of Exponential Averaging If we expand the formula, we get: e n+1 = α t n +(1 α) α t n-1 + +(1 α ) j α t n-j + +(1 α ) n+1 e 0 Since both α and (1 α) are less than or equal to 1, each successive term has less weight than its predecessor (recent past counts more) Priority Scheduling A priority number is associated with each process. The CPU is allocated to the process with the highest priority (smallest integer = highest priority). SJN is a priority scheduling where priority is the inverse of the predicted next CPU burst time. Problem: Starvation low priority processes may never execute. Solution: Aging as time progresses, increase the priority of the process. 17

Example of Priority Scheduling ProcessAarri Burst TimeTPriority P 1 10 3 P 2!1 1 P 3 2 4 P 4 1 5 P 5!5 2 Scheduling chart convention: low integer means high priority P 2 P 5 P 1 P 3 P 4 0 1 6 16 18 19 Average waiting time = 8.2 msec! 35 Multi-Level Feedback Queue Scheduling Split the Ready list into a number of queues: queue 0, queue 1, queue 2, and so on. Lower-numbered queues have higher priority. When the current process is interrupted at the end of its quantum, a new process is selected from the front of the highest priority queue that has any processes. The word feedback refers to the fact that processes can move from one queue to another. 18

Multilevel Feedback Queue Example Process created: - Give high priority and short time slice If process uses up the time slice without blocking: - priority = priority + 1 (lower its priority) - time_slice = time_slice * 2; Three queues: Q0 time quantum 8 ms Q1 time quantum 16 ms Q2 FCFS Multilevel Feedback Queue Example Scheduling - A new process enters queue Q 0 which is served FCFS. When it gains CPU, the process receives 8 milliseconds. If it does not finish in 8 milliseconds, the process is moved to queue Q 1. - A Q 1 process is again served FCFS and receives 16 additional milliseconds. If it still does not complete, it is preempted and moved to queue Q 2. - A Q2 process is served FCFS Attacks both efficiency and response time problems - Efficiency: long time quanta = low switching overhead - Response time: quickly run after becoming unblocked 19

FB Variants Scheduler defined by the following parameters: - number of queues - scheduling algorithms for each queue - method used to determine when to upgrade a process - method used to determine when to demote a process - method used to determine which queue a process will enter when that process needs service Windows Operating System - 32 priority levels - Decrease priority at timer interrupts - Increase priority at I/O events Traditional UNIX Scheduling Uses multilevel feedback queues 128 priorities possible (0-127) One Round Robin queue per priority At every scheduling event, the scheduler - picks the non-empty queue of highest priority - runs processes in round-robin Scheduling events: - Clock interrupt - Process does a system call - Process gives up CPU (for instance, to do I/O) 20

Linux - Lottery Scheduling Give each process some number of tickets At each scheduling event, randomly pick a ticket Run winning process More tickets implies more CPU time How to use? - approximate priority: low priority, give few tickets; high priority, give many tickets - approximates SRT: short processes, give more tickets; long processes, fewer tickets If a job has at least one ticket, it won t starve Summary FIFO: + simple RR: - short jobs can get stuck behind long ones; poor I/O + better for short jobs - poor when jobs are the same length SJF: + optimal - hard to predict the future - unfair to long running jobs Priority: + behavior-dependent + approximate SRTF - still unfair to long running jobs 21