CPU Scheduling. CPU Scheduler

Similar documents
Chapter 6: CPU Scheduling

Module 5: CPU Scheduling

CPU scheduling. CPU Scheduling

2/5/07 CSE 30341: Operating Systems Principles

TDDI04, K. Arvidsson, IDA, Linköpings universitet CPU Scheduling. Overview: CPU Scheduling. [SGG7] Chapter 5. Basic Concepts.

CS 550 Operating Systems Spring CPU scheduling I

Che-Wei Chang Department of Computer Science and Information Engineering, Chang Gung University

TDDB68 Concurrent programming and operating systems. Lecture: CPU Scheduling II

CHAPTER 5 - PROCESS SCHEDULING

CPU SCHEDULING RONG ZHENG

CSCE 313 Introduction to Computer Systems. Instructor: Dezhen Song

Last class: Today: Threads. CPU Scheduling

Process Scheduling. Process Scheduling. CPU and I/O Bursts. CPU - I/O Burst Cycle. Variations in Bursts. Histogram of CPU Burst Times

CPU Scheduling Exercises

Comp 204: Computer Systems and Their Implementation. Lecture 11: Scheduling cont d

CPU Scheduling. Heechul Yun

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

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

CSE 380 Computer Operating Systems

Simulation of Process Scheduling Algorithms

CS 370. FCFS, SJF and Round Robin. Yashwanth Virupaksha and Abhishek Yeluri

Scheduling. Uwe R. Zimmer & Alistair Rendell The Australian National University

UC Santa Barbara. Operating Systems. Christopher Kruegel Department of Computer Science UC Santa Barbara

Real-time operating systems course. 6 Definitions Non real-time scheduling algorithms Real-time scheduling algorithm

Improvising Round Robin Process Scheduling through Dynamic Time Quantum Estimation

Dynamic Time Quantum based Round Robin CPU Scheduling Algorithm

Design and Performance Evaluation of a New Proposed Shortest Remaining Burst Round Robin (SRBRR) Scheduling Algorithm

Journal of Global Research in Computer Science

Revamped Round Robin Scheduling Algorithm

ENHANCING CPU PERFORMANCE USING SUBCONTRARY MEAN DYNAMIC ROUND ROBIN (SMDRR) SCHEDULING ALGORITHM

LSN 15 Processor Scheduling

DETERMINING THE VARIABLE QUANTUM TIME (VQT) IN ROUND ROBIN AND IT S IMPORTANCE OVER AVERAGE QUANTUM TIME METHOD

Season Finale: Which one is better?

Half Life Variable Quantum Time Round Robin (HLVQTRR)

COMPARATIVE PERFORMANCE ANALYSIS OF MULTI-DYNAMIC TIME QUANTUM ROUND ROBIN (MDTQRR) ALGORITHM WITH ARRIVAL TIME

Discrete Event Simulation. Motive

ODSA: A Novel Ordering Divisional Scheduling Algorithm for Modern Operating Systems

An Improved Round Robin Approach using Dynamic Time Quantum for Improving Average Waiting Time

February 2011 Page 23 of 93 ISSN

A new Hybridized Multilevel Feedback Queue Scheduling with Intelligent Time Slice and its Performance Analysis

EXTRA THRESHOLD IN ROUND ROBIN ALGORITHM IN MULTIPROCESSOR SYSTEM

Journal of Global Research in Computer Science

ENHANCING THE CPU PERFORMANCE USING A MODIFIED MEAN- DEVIATION ROUND ROBIN SCHEDULING ALGORITHM FOR REAL TIME SYSTEMS.

Networked Embedded Systems WS 2016/17

Efficient Dual Nature Round Robin CPU Scheduling Algorithm: A Comparative Analysis

Determining the Optimum Time Quantum Value in Round Robin Process Scheduling Method

A NEW PROPOSED DYNAMIC DUAL PROCESSOR BASED CPU SCHEDULING ALGORITHM

Operational Laws Raj Jain

Improved Deadline Monotonic Scheduling With Dynamic and Intelligent Time Slice for Real-time Systems

International Journal of Advanced Research in Computer Science and Software Engineering

Real-Time Systems. Event-Driven Scheduling

CIS 4930/6930: Principles of Cyber-Physical Systems

Aperiodic Task Scheduling

ENHANCING THE CPU PERFORMANCE USING A MODIFIED MEAN- DEVIATION ROUND ROBIN SCHEDULING ALGORITHM FOR REAL TIME SYSTEMS

Introduction to Queueing Theory

COMP9334: Capacity Planning of Computer Systems and Networks

Task Models and Scheduling

ENHANCED ROUND ROBIN ALGORITHM FOR PROCESS SCHEDULING USING VARYING QUANTUM PRECISION

Generating Random Variables

Scheduling Slack Time in Fixed Priority Pre-emptive Systems

Proportional Share Resource Allocation Outline. Proportional Share Resource Allocation Concept

3. Scheduling issues. Common approaches 3. Common approaches 1. Preemption vs. non preemption. Common approaches 2. Further definitions

Lecture Note #6: More on Task Scheduling EECS 571 Principles of Real-Time Embedded Systems Kang G. Shin EECS Department University of Michigan

Scheduling IoT on to the Cloud : A New Algorithm

Computing the Signal Duration to Minimize Average Waiting Time using Round Robin Algorithm

Lecture 6. Real-Time Systems. Dynamic Priority Scheduling

PBS: A Unified Priority-Based CPU Scheduler

Convolution Algorithm

Analysis of Software Artifacts

Introduction to Queueing Theory

Introduction to Queueing Theory

Operational Laws 33-1

Process Scheduling for RTS. RTS Scheduling Approach. Cyclic Executive Approach

CPSC 531: System Modeling and Simulation. Carey Williamson Department of Computer Science University of Calgary Fall 2017

Andrew Morton University of Waterloo Canada

Non-Preemptive and Limited Preemptive Scheduling. LS 12, TU Dortmund

Embedded Systems 14. Overview of embedded systems design

Real-Time Scheduling. Real Time Operating Systems and Middleware. Luca Abeni

Section 1.2: A Single Server Queue

Real-Time and Embedded Systems (M) Lecture 5

Exercises Stochastic Performance Modelling. Hamilton Institute, Summer 2010

Scheduling Online Algorithms. Tim Nieberg

Clock-driven scheduling

CEC 450 Real-Time Systems

Research Article Designing of Vague Logic Based 2-Layered Framework for CPU Scheduler

Lecture 13. Real-Time Scheduling. Daniel Kästner AbsInt GmbH 2013

How to deal with uncertainties and dynamicity?

COMP9334 Capacity Planning for Computer Systems and Networks

Operational Laws. Operational Laws. Overview. Operational Quantities

NATCOR: Stochastic Modelling

Real-Time Systems. Event-Driven Scheduling

Embedded Systems 15. REVIEW: Aperiodic scheduling. C i J i 0 a i s i f i d i

Embedded Systems Development

CS418 Operating Systems

AstroPortal: A Science Gateway for Large-scale Astronomy Data Analysis

Chapter 10. Queuing Systems. D (Queuing Theory) Queuing theory is the branch of operations research concerned with waiting lines.

M/G/1 and Priority Queueing

There are three priority driven approaches that we will look at

Real-Time Systems. Lecture #14. Risat Pathan. Department of Computer Science and Engineering Chalmers University of Technology

Paper Presentation. Amo Guangmo Tong. University of Taxes at Dallas January 24, 2014

Transcription:

CPU Scheduling These slides are created by Dr. Huang of George Mason University. Students registered in Dr. Huang s courses at GMU can make a single machine readable copy and print a single copy of each slide for their own reference as long as the slide contains the copyright statement, and the GMU facilities are not used to produce the paper copies. Permission for any other use, either in machine-readable or printed form, must be obtained form the author in writing. CS471 1 CPU Scheduler Selects from among the processes in memory that are ready to execute, and allocates the CPU to one of them. CPU scheduling decisions may take place 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 5. Time slices expires Scheduling under 1 and 4 is nonpreemptive. 5 is preemptive. CS471 2 1

Processing and IO Cycles Process execution consists of a cycle of CPU execution and I/O wait CS471 3 Type of Applictions From the Viewpoint of Scheduling CPU bound long CPU bursts and short IO bursts Spend most times in computing Number crunching applications I/O bound Short CPU bursts and long IO bursts Spend most times in IO Interactive and database applications CS471 4 2

Dispatcher Dispatcher module gives control of the CPU to the process selected by the short-term scheduler; this involves: switching context switching to user mode jumping to the proper location in the user program to restart that program Dispatch latency time it takes for the dispatcher to stop one process and start another running. CS471 5 Scheduling Criteria CPU utilization keep the CPU as busy as possible Throughput # of processes that complete their execution per time unit Turnaround time amount of time to execute a particular process CS471 6 3

Waiting time amount of time a process has been waiting in the ready queue Response time amount of time it takes from when a request was submitted until the first response is produced, not output (for timesharing environment) CS471 7 Optimization Criteria Max CPU utilization Max throughput Min turnaround time Min waiting time Min response time CS471 8 4

First-Come, First-Served Scheduling Process Burst Time P 1 24 P 2 3 P 3 3 Processes arrive in the order: P 1, P 2, P 3 The Gantt Chart for the schedule is: P 1 P 2 P 3 0 24 27 30 Waiting time for P 1 = 0; P 2 = 24; P 3 = 27 Average waiting time: (0 + 24 + 27)/3 = 17 CS471 9 FCFS Scheduling (Cont.) Suppose that the processes arrive in the order P 2, P 3, P 1. We have P 2 P 3 P 1 0 3 6 30 Waiting time for P 1 = 6; P 2 = 0 ; P 3 = 3 Average waiting time: (6 + 0 + 3)/3 = 3 Much better than previous case. CS471 10 5

Shortest-Job-First (SJR) Scheduling Associate with each process the length of its next CPU burst. Use these lengths to schedule the process with the shortest time. Nonpreemptive once CPU given to the process it cannot be preempted until completes its CPU burst. CS471 11 Preemptive if a new process arrives with CPU burst length less than remaining time of current executing process, preempt. This scheme is know as the Shortest-Remaining-Time-First (SRTF). SJF is optimal gives minimum average waiting time for a given set of processes. CS471 12 6

Example of Non-Preemptive SJF Process Arrival Time Burst Time P 1 0.0 7 P 2 2.0 4 P 3 4.0 1 P 4 5.0 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 CS471 13 Example of Preemptive SJF Process Arrival Time Burst Time P 1 0.0 7 P 2 2.0 4 P 3 4.0 1 P 4 5.0 4 SJF (preemptive) P 1 P 2 P 3 P 4 P 2 P 1 0 2 4 5 7 11 16 Average waiting time = (9 + 1 + 0 +2)/4-3 CS471 14 7

Determining Length of Next CPU Burst Can only estimate the length. Can be done by using the length of previous CPU bursts, using exponential averaging. 1. t n = actual lenght of n 2. 3. α, 0 α 1 4. τ n + 1 = predicted value for the next CPU burst Define : th CPU burst τ n= 1 = α tn + 1 ( α ) τ. n CS471 15 If we expand the formula, we get: τ n+1 = α t n +(1 - α) α t n -1 + +(1 - α ) j α t n -1 + +(1 - α ) n=1 t n τ 0 Since both α and (1 - α) are less than or equal to 1, each successive term has less weight than its predecessor. CS471 16 8

Prediction vs Reality CS471 17 Round Robin (RR) Each process gets a small slice of CPU time (time quantum), usually 10-100 milliseconds. After this time has elapsed, the process is preempted and added to the end of the ready queue. If there are n processes in the ready queue and the time quantum is q, then each process gets 1/n of the CPU time in chunks of at most q time units at once. No process waits more than (n-1)q time units. CS471 18 9

Performance q large FIFO q small q must be large with respect to context switch, otherwise overhead is too high. With Pentium Pro 200MHz, context switching time is about 15 msec. CS471 19 Time Quantum and Context Switch Time CS471 20 10

Example of RR, Time Quantum = 20 Process Burst Time P 1 53 P 2 17 P 3 68 P 4 24 The Gantt chart is: P 1 P 2 P 3 P 4 P 1 P 3 P 4 P 1 P 3 P 3 0 20 37 57 77 97 117 121 134 154 162 Typically, higher average turnaround than SJF, but better response. CS471 21 Priority Scheduling A priority number (integer) is associated with each process The CPU is allocated to the process with the highest priority (smallest integer highest priority). Problem Starvation low priority processes may never execute. Solution Aging as time progresses increase the priority of the process. CS471 22 11

Multilevel Queue Ready queue is partitioned into separate queues: foreground (interactive) background (batch) Each queue has its own scheduling algorithm, foreground RR background FCFS CS471 23 Scheduling must be done between the queues. Fixed priority scheduling; (i.e., serve all from foreground then from background). Possibility of starvation. Time slice each queue gets a certain amount of CPU time which it can schedule amongst its processes; i.e., 80% to foreground in RR 20% to background in FCFS CS471 24 12

Multilevel Queue Scheduling CS471 25 Multilevel Feedback Queue A process can move between the various queues; aging can be implemented this way. Multilevel-feedback-queue 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 CS471 26 13

Example of Multilevel Feedback Queue Three queues: Q 0 time quantum 8 milliseconds Q 1 time quantum 16 milliseconds Q 2 FCFS CS471 27 Scheduling A new job enters queue Q 0 which is served FCFS. When it gains CPU, job receives 8 milliseconds. If it does not finish in 8 milliseconds, job is moved to queue Q 1. At Q 1 job is again served FCFS and receives 16 additional milliseconds. If it still does not complete, it is preempted and moved to queue Q 2. Notice: completion means reaching the end of the current CPU burst. CS471 28 14

Real-Time Scheduling Hard real-time systems required to complete a critical task within a guaranteed amount of time. An important subjet on its own But we will not discuss it further Soft real-time computing requires that critical processes receive priority over less fortunate ones. Important for interactive applications, gaming CS471 29 Linux Process Scheduling The basic time unit is a tick = 10 msec. The nice level of a process ranges from -20 to 19 (the higher the value, the nicer the process is to others). The remaining time quantum of the process is recorded in couter (in ticks). A task is runnable if it is in the RUNNING state and its quantum has not run out (counter>0). The scheduler finds the runnable process with the highest (counter nice). CS471 30 15

When the couter of all runnable processes reaches zero, all processes are updated as follows. couter = courter/2 + (20-nice+1); For a runnable process (whose original couter=0), this restores its quantum to (20-nice+1), ranging from 2 to 40. CS471 31 Notice that even waiting processes (whose original couter>0) are updated as above. This give advantages to IO-bound processes in two ways: They have higher priority when ready to run They can run longer when ready to run. Notice that interactive applications are IO bound. Can you see that aging is supported to avoid starvation? CS471 32 16

Discussions Several problems of Linux scheduling are known. Recompute couters of all processes take too much time in large scale systems. With large numbers of processes, the events of quantums exhausted for all runnables occur seldom, leaving interactive applications not boosted often enough Some people find Linux not smooth under load. CS471 33 Scheduling in Windows 2000 Support 32 levels of priority. Windows 2000 API provides 6 classes: Real time, High priority, above normal, normal priority, Below normal, Idle. There are 7 relative priorities. Time critical, highest, above normal, normal, below normal, lowest, idle CS471 34 17

Windows 2000 Priorities Also called variable class CS471 35 When a task of the variable class uses up its quantum, its priority is lowered. CPU bound applications receive low priorities When a task waits on an IO operation, its priority is raised. The amount of priority boost depends on what the task is waiting for. small boosts to disk large boosts to keyboard/mouse The result: interactive applications receive have high priorities. CS471 36 18