CS 153 Design of Operating Systems Winter 2016

Similar documents
CPU Scheduling. Jo, Heeseung

Comp 204: Computer Systems and Their Implementation. Lecture 10: Process 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. Jo, Heeseung

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

CPU scheduling. CPU Scheduling

CPU Scheduling: Part I. Operating Systems. Spring CS5212

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

CPU Scheduling. Chapter 9

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

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

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

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

Scheduling. CSE Computer Systems November 19, 2001

SE350: Operating Systems. Lecture 6: Scheduling

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

א א א א א א א א

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

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

CS 143A - Principles of Operating Systems

Principles of Operating Systems

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

CSE 5343/7343 Fall 2006 PROCESS SCHEDULING

CPU Scheduling (Chapters 7-11)

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)

Lecture 11: CPU Scheduling

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

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

Project 2 solution code

CSC 553 Operating Systems

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

Motivation. Types of Scheduling

CS510 Operating System Foundations. Jonathan Walpole

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

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

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

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

CSE 451: Operating Systems Spring Module 8 Scheduling

CS 111. Operating Systems Peter Reiher

IJCSC VOLUME 5 NUMBER 2 JULY-SEPT 2014 PP ISSN

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

Simulation of Process Scheduling Algorithms

September 30 th, 2015 Prof. John Kubiatowicz

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

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

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

Chapter 9 Uniprocessor Scheduling

Operating Systems. Scheduling

Operating System 9 UNIPROCESSOR SCHEDULING

Uniprocessor Scheduling

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

Journal of Global Research in Computer Science

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

Operating Systems Process Scheduling Prof. Dr. Armin Lehmann

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

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

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 II. To do. q Proportional-share scheduling q Multilevel-feedback queue q Multiprocessor scheduling q Next Time: Memory management

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

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

A Paper on Modified Round Robin Algorithm

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

A COMPARATIVE ANALYSIS OF SCHEDULING ALGORITHMS

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

Motivating Examples of the Power of Analytical Modeling

CS 425 / ECE 428 Distributed Systems Fall 2018

CS 425 / ECE 428 Distributed Systems Fall 2017

Pallab Banerjee, Probal Banerjee, Shweta Sonali Dhal

Asia Pacific Journal of Engineering Science and Technology

Advanced Types Of Scheduling

Scheduling: Introduction

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

Comparative Analysis of Basic CPU Scheduling Algorithms

SELF OPTIMIZING KERNEL WITH HYBRID SCHEDULING ALGORITHM

Periodic task scheduling

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

Improving Throughput and Utilization in Parallel Machines Through Concurrent Gang

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.

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

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

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

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

CS 318 Principles of Operating Systems

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

Improvement of Queue Management for Real Time Task in Operating System

Mixed Round Robin Scheduling for Real Time Systems

ENGG4420 CHAPTER 4 LECTURE 3 GENERALIZED TASK SCHEDULER

Queue based Job Scheduling algorithm for Cloud computing

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

DRR Based Job Scheduling for Computational Grid and its Variants

Homework 2: Comparing Scheduling Algorithms

Operating Systems (234123) Spring 2013 Scheduling Dan Tsafrir (18/3/2013, 8/4/2013)

GENERALIZED TASK SCHEDULER

A SURVEY ON TRADITIONAL AND EARLIER JOB SCHEDULING IN CLOUD ENVIRONMENT

Gang Scheduling Performance on a Cluster of Non-Dedicated Workstations

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

Transcription:

CS 153 Design of Operating Systems Winter 2016 Lecture 11: Scheduling

Scheduling Overview Scheduler runs when we context switching among processes/threads on the ready queue What should it do? Does it matter? Making this decision is called scheduling Now, we ll look at: The goals of scheduling Starvation Various well-known scheduling algorithms Standard Unix scheduling algorithm 2

Multiprogramming In a multiprogramming system, we try to increase CPU utilization and job throughput by overlapping I/O and CPU activities Doing this requires a combination of mechanisms and policy We have covered the mechanisms Context switching, how and when it happens Process queues and process states Now we ll look at the policies Which process (thread) to run, for how long, etc. We ll refer to schedulable entities as jobs (standard usage) could be processes, threads, people, etc. 3

Scheduling Goals Scheduling works at two levels in an operating system 1. To determine the multiprogramming level the number of jobs loaded into primary memory» Moving jobs to/from memory is often called swapping» Long term scheduler: infrequent 2. To decide what job to run next to guarantee good service» Good service could be one of many different criteria» Short term scheduler: frequent» We are concerned with this level of scheduling» Is scheduler a thread always running in kernel space? (Use your PintOS experience) 4

Scheduling The scheduler (aka dispatcher) is the module that manipulates the queues, moving jobs to and from them The scheduling algorithm determines which jobs are chosen to run next and what queues they wait on In general, the scheduler runs, when PintOS calls next_thread_to_run: When a job switches from running to waiting When an interrupt occurs When a job is created or terminated The scheduler runs inside the kernel. Therefore, kernel has to be entered before scheduler can run. 5

Preemptive vs. Nonpreemptive scheduling We ll discuss scheduling algorithms in two contexts In preemptive systems the scheduler can interrupt a running job (involuntary context switch) In non-preemptive systems, the scheduler waits for a running job to explicitly block (voluntary context switch) 6

Scheduling Goals What are some reasonable goals for a scheduler? Scheduling algorithms can have many different goals: CPU utilization Job throughput (# jobs/unit time) Turnaround time (T finish T start ) Waiting time (Avg(T wait ): avg time spent on wait queues) Response time (Avg(T ready ): avg time spent on ready queue) Batch systems Strive for job throughput, turnaround time (supercomputers) Interactive systems Strive to minimize response time for interactive jobs (PC) 7

Starvation Starvation is a scheduling non-goal : Starvation is a situation where a process is prevented from making progress because some other process has the resource it requires Resource could be the CPU, or a lock (recall readers/writers) Starvation usually a side effect of the sched. algorithm A high priority process always prevents a low priority process from running on the CPU One thread always beats another when acquiring a lock Starvation can be a side effect of synchronization Constant supply of readers always blocks out writers 8

First In First Out (FIFO) Schedule tasks in the order they arrive Continue running them until they complete or give up the processor Example: many cases in real life On what workloads is FIFO particularly bad? Imagine being at supermarket to buy a drink of water, but get stuck behind someone with a huge cart (or two!)» and who pays in pennies! Can we do better? 9

Shortest Job First (SJF) Always do the task that has the shortest remaining amount of work to do Often called Shortest Remaining Time First (SRTF) Suppose we have five tasks arrive one right after each other, but the first one is much longer than the others Which completes first in FIFO? Next? Which completes first in SJF? Next? 10

FIFO vs. SJF Whats the big deal? Don t they finish at the same time? 11

Average Turnaround Time (ATT) FIFO: ATT = (8 + (8+4)+(8+4+2))/3 = 11.33 ATT = (4 + (4+8)+(4+8+2))/3 = 10 ATT = (4+ (4+2)+(4+2+8))/3 = 8 SJF: ATT = (2 + (2+4)+(2+4+8))/3 = 7.33 12

Average Response Time (ART) FIFO: ART = (0 + 8 + (8+4))/3 = 6.67 ART = (0 + 4 + (4+8))/3 = 5.33 ART = (0 + 4 + (4+2))/3 = 3.33 SJF: ART = (0 + 2 + (2+4))/3 = 2.67 13

SJF Claim: SJF is optimal for average response time Why? For what workloads is FIFO optimal? For what is it pessimal (i.e., worst)? Does SJF have any downsides? Does it work in a supermarket? 14

Shortest Job First (SJF) Problems? Impossible to know size of CPU burst» Like choosing person in line without looking inside basket/cart How can you make a reasonable guess? Can potentially starve Flavors Can be either preemptive or non-preemptive Preemptive SJF is called shortest remaining time first (SRTF) 15

Round Robin Each task gets resource for a fixed period of time (time quantum) If task doesn t complete, it goes back in line Need to pick a time quantum What if time quantum is too long?»infinite? What if time quantum is too short?»one instruction? 16

Round Robin 17

Round Robin vs. FIFO Many context switches can be costly Other than that, is Round Robin always better than FIFO, in terms of average response time or average turnaround time? 18

Round Robin vs. FIFO Is Round Robin always fair? 19

Next Class Deadlock continued 22