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

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

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

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

CPU Scheduling: Part I. Operating Systems. Spring CS5212

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

א א א א א א א א

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

CPU scheduling. CPU Scheduling

CPU Scheduling. Chapter 9

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

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

CS 143A - Principles of Operating Systems

Principles of Operating Systems

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

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

Scheduling. CSE Computer Systems November 19, 2001

CSE 5343/7343 Fall 2006 PROCESS SCHEDULING

Simulation of Process Scheduling Algorithms

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

CPU Scheduling. Jo, Heeseung

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

CS 153 Design of Operating Systems Winter 2016

CSC 553 Operating Systems

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)

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

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

Journal of Global Research in Computer Science

CPU Scheduling. Jo, Heeseung

Motivation. Types of Scheduling

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

Chapter 9 Uniprocessor Scheduling

Operating System 9 UNIPROCESSOR SCHEDULING

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

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

IJCSC VOLUME 5 NUMBER 2 JULY-SEPT 2014 PP ISSN

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

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

Lecture 11: CPU Scheduling

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

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

Asia Pacific Journal of Engineering Science and Technology

Comparative Analysis of Basic CPU Scheduling Algorithms

CPU Scheduling. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

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

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

Uniprocessor Scheduling

CPU Scheduling. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

SE350: Operating Systems. Lecture 6: Scheduling

A Paper on Modified Round Robin Algorithm

CS510 Operating System Foundations. Jonathan Walpole

Pallab Banerjee, Probal Banerjee, Shweta Sonali Dhal

Project 2 solution code

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

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

CPU Scheduling (Chapters 7-11)

Operating Systems Process Scheduling Prof. Dr. Armin Lehmann

CS 111. Operating Systems Peter Reiher

September 30 th, 2015 Prof. John Kubiatowicz

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

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

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

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:

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

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

A NOVEL METHOD BASED ON PRIORITY FOR ENHANCEMENT ROUND-ROBIN SCHEDULING ALGORITHM

Advanced Types Of Scheduling

Mixed Round Robin Scheduling for Real Time Systems

A COMPARATIVE ANALYSIS OF SCHEDULING ALGORITHMS

Improvised Optimum Multilevel Dynamic Round Robin Algorithm for Optimizing CPU Scheduling

ENGG4420 CHAPTER 4 LECTURE 3 GENERALIZED TASK SCHEDULER

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)?

Bhavin Fataniya 1, Manoj Patel 2 1 M.E(I.T) Student, I.T Department, L.D College Of Engineering, Ahmedabad, Gujarat, India ABSTRACT I.

CSE 451: Operating Systems Spring Module 8 Scheduling

Efficient Round Robin Scheduling Algorithm with Dynamic Time Slice

Queue based Job Scheduling algorithm for Cloud computing

Improvement of Queue Management for Real Time Task in Operating System

GENERALIZED TASK SCHEDULER

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

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

Operating Systems. Scheduling

Design and Performance Evaluation of Smart Job First Dynamic Round Robin (SJFDRR) Scheduling Algorithm with Smart Time Quantum

A New Proposed Dynamic Quantum for Priority Based Round Robin Scheduling Algorithm

ELC 4438: Embedded System Design Real-Time Scheduling

DEADLINE MONOTONIC ALGORITHM (DMA)

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

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

SELF OPTIMIZING KERNEL WITH HYBRID SCHEDULING ALGORITHM

SCHEDULING AND CONTROLLING PRODUCTION ACTIVITIES

Homework 2: Comparing Scheduling Algorithms

Scheduling: Introduction

IJRASET: All Rights are Reserved

Comparative Study of Parallel Scheduling Algorithm for Parallel Job

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

TASK SCHEDULING BASED ON EFFICIENT OPTIMAL ALGORITHM IN CLOUD COMPUTING ENVIRONMENT

Real-Time Scheduler Design For Embedded System Domain

DRR Based Job Scheduling for Computational Grid and its Variants

Clock-Driven Scheduling

Real-Time and Embedded Systems (M) Lecture 4

2. Scheduling issues. Common approaches /2. Common approaches /1. Common approaches / /18 UniPD - T. Vardanega 14/03/2018

Transcription:

CSE 421/521 - Operating Systems Fall 2011 Lecture - V CPU Scheduling - I Tevfik Koşar University at Buffalo September 13 th, 2011 1 Roadmap CPU Scheduling Basic Concepts Scheduling Criteria & Metrics Different Scheduling Algorithms FCFS SJF Priority RR 2

Basic Concepts Multiprogramming is needed for efficient CPU utilization CPU Scheduling: deciding which processes to execute when Process execution begins with a CPU burst, followed by an I/O burst CPU I/O Burst Cycle Process execution consists of a cycle of CPU execution and I/O wait 3 Alternating Sequence of CPU And I/O Bursts 4

Histogram of CPU-burst Durations 5 Process State As a process executes, it changes state new: The process is being created ready: The process is waiting to be assigned to a process running: Instructions are being executed waiting: The process is waiting for some event to occur terminated: The process has finished execution 6

CPU Scheduler Selects from among the processes in memory that are ready to execute, and allocates the CPU to one of them! short-term scheduler 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. A new process arrives Scheduling under 1 and 4 is nonpreemptive/cooperative Once a process gets the CPU, keeps it until termination/switching to waiting state/release of the CPU All other scheduling is preemptive Most OS use this Cost associated with access to shared data i.e. time quota expires 7 Dispatcher Dispatcher module gives control of the CPU to the process selected by the short-term scheduler; Its function 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 8

Scheduling Criteria CPU utilization keep the CPU as busy as possible --> maximize Throughput # of processes that complete their execution per time unit -->maximize Turnaround time amount of time passed to finish execution of a particular process --> minimize i.e. execution time + waiting time Waiting time total amount of time a process has been waiting in the ready queue -->minimize Response time amount of time it takes from when a request was submitted until the first response is produced, not output (for time-sharing environment) -->minimize 9 Optimization Criteria Maximize CPU utilization Maximize throughput Minimize turnaround time Minimize waiting time Minimize response time 10

! Scheduling metrics Scheduling Metrics " arrival time t a = time the process became Ready (again) " wait time T w = time spent waiting for the CPU " service time T s = time spent executing in the CPU " turnaround time T r = total time spent waiting and executing t a = T w + T s Arrival times #5 arrived T w T s Execution times T r #5 executed T r / T s = 2.5 11 First-Come, First-Served (FCFS) Scheduling " processes are assigned the CPU in the order they request it " when the running process blocks, the first Ready is run next " when a process gets Ready, it is put at the end of the queue Arrival times A B C D E A B C D E Mean FCFS scheduling policy Stallings, W. (2004) Operating Systems: Internals and Design Principles (5th Edition). 12

FCFS Scheduling - Example Process Burst Time P 1 24 P 2 3 P 3 3 Suppose that the 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 13 FCFS Scheduling - Example Suppose that the processes arrive in the order P 2, P 3, P 1 The Gantt chart for the schedule is: 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 Convoy effect short process behind long process 14

Shortest-Job-First (SJF) Scheduling Associate with each process the length of its next CPU burst. Use these lengths to schedule the process with the shortest time Two schemes: nonpreemptive once CPU given to the process it cannot be preempted until completes its CPU burst 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 15 Non-Preemptive SJF " nonpreemptive, assumes the run times are known in advance " among several equally important Ready jobs (or CPU bursts), the scheduler picks the one that will finish the earliest Arrival times A B C D E Shortest Job First (SJF) SJF A B C D E Mean SJF scheduling policy Stallings, W. (2004) Operating Systems: Internals and Design Principles (5th Edition). 16

Non-Preemptive SJF - Example 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) Gantt Chart P 1 P 3 P 2 P 4 0 3 7 8 12 16 Average waiting time = (0 + 6 + 3 + 7)/4 = 4 17 Preemptive SJF (SRT)! Shortest Remaining Time (SRT) " preemptive version of SJF, also assumes known run time " choose the process whose remaining run time is shortest " allows new short jobs to get good service Arrival times A B C D E A B C D E Mean SRT scheduling policy Stallings, W. (2004) Operating Systems: Internals and Design Principles (5th Edition). 18

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) Gantt Chart P 1 P 2 P 3 P 2 P 4 P 1 0 2 4 5 7 11 16 19 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) Preemptive nonpreemptive SJF is a priority scheduling where priority is 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 20

Example of Priority Process Arrival Time Burst Time Priority P 1 0.0 7 2 P 2 2.0 4 1 P 3 4.0 1 4 P 4 5.0 4 3 Priority (non-preemptive) P1 --> P2 --> P4 --> P3 Priority (preemptive)?? 21 Round Robin (RR) Each process gets a small unit 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. Performance q large FIFO q small q must be large with respect to context switch, otherwise overhead is too high 22

Round Robin (RR) " preemptive FCFS, based on a timeout interval, the quantum q " the running process is interrupted by the clock and put last in a FIFO Ready queue; then, the first Ready process is run instead Arrival times A B C D E A B C D E Mean RR (q = 1) scheduling policy Stallings, W. (2004) Operating Systems: Internals and Design Principles (5th Edition). 23 Round Robin (RR) " a crucial parameter is the quantum q (generally ~10 100ms) # q should be big compared to context switch latency (~10µs) # q should be less than the longest CPU bursts, otherwise RR degenerates to FCFS Arrival times A B C D E A B C D E Mean RR (q = 4) scheduling policy Stallings, W. (2004) Operating Systems: Internals and Design Principles (5th Edition). 24

Example of RR with Time Quantum = 20 Process Burst Time P 1 53 P 2 17 P 3 68 P 4 24 For q=20, 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 25 Time Quantum and Context Switch Time 26

Turnaround Time Varies With The Time Quantum 27 Exercise Draw gantt charts, find average turnaround and waiting times for above processes, considering: 1) First Come First Served Scheduling 2) Shortest Job First Scheduling (non-preemptive) 3) Shortest Job First Scheduling (preemptive) 4) Round-Robin Scheduling 5) Priority Scheduling (non-preemptive) 6) Priority Scheduling (preemptive) 28

Summary CPU Scheduling Basic Concepts Scheduling Criteria & Metrics Different Scheduling Algorithms FCFS SJF Priority RR Hmm.. Next Lecture: Project Overview Reading Assignment: Chapter 5 from Silberschatz. 29 Acknowledgements Operating Systems Concepts book and supplementary material by A. Silberschatz, P. Galvin and G. Gagne Operating Systems: Internals and Design Principles book and supplementary material by W. Stallings Modern Operating Systems book and supplementary material by A. Tanenbaum R. Doursat and M. Yuksel from UNR 30