Operating Systems. Lecture Process Scheduling. Golestan University. Hossein Momeni

Similar documents
Operating Systems. Scheduling

Last Class: Processes

CPU Scheduling. CSE 2431: Introduction to Operating Systems Reading: Chapter 6, [OSC] (except Sections )

Properties of Processes

Chapter 5: CPU Scheduling

CPU Scheduling Algorithms

CISC 7310X. C05: CPU Scheduling. Hui Chen Department of Computer & Information Science CUNY Brooklyn College. 3/1/2018 CUNY Brooklyn College

Chapter 6: CPU Scheduling

OPERATING SYSTEMS CS3502 Spring Processor Scheduling. Chapter 5

CS3733: Operating Systems

8: Scheduling. Scheduling. Mark Handley

CSE120 Principles of Operating Systems. Prof Yuanyuan (YY) Zhou Scheduling

Scheduling in the Supermarket

CPU Scheduling. Schedulers. CPSC 313: Intro to Computer Systems. Intro to Scheduling. Schedulers in the OS

Operating System Concepts Ch. 5: Scheduling

Lecture 5 / Chapter 6 (CPU Scheduling) Basic Concepts. Scheduling Criteria Scheduling Algorithms

Lecture Topics. Announcements. Today: Uniprocessor Scheduling (Stallings, chapter ) Next: Advanced Scheduling (Stallings, chapter

CS370 Operating Systems

Course Syllabus. Operating Systems

Process Scheduling. Copyright : University of Illinois CS 241 Staff

Preview. Process Scheduler. Process Scheduling Algorithms for Batch System. Process Scheduling Algorithms for Interactive System

Scheduling of processes

CS370 Operating Systems

Announcements. Program #1. Program #0. Reading. Is due at 9:00 AM on Thursday. Re-grade requests are due by Monday at 11:59:59 PM.

1.1 CPU I/O Burst Cycle

LECTURE 3:CPU SCHEDULING

Operating Systems ECE344. Ding Yuan

Chapter 6: CPU Scheduling. Operating System Concepts 9 th Edition

CS370: System Architecture & Software [Fall 2014] Dept. Of Computer Science, Colorado State University

CPU Scheduling. Operating Systems (Fall/Winter 2018) Yajin Zhou ( Zhejiang University

Chapter 5 CPU scheduling

Chapter 5: CPU Scheduling. Operating System Concepts 8 th Edition,

OPERATING SYSTEMS. After A.S.Tanenbaum, Modern Operating Systems, 3rd edition. Uses content with permission from Assoc. Prof. Florin Fortis, PhD

CPU Scheduling. Daniel Mosse. (Most slides are from Sherif Khattab and Silberschatz, Galvin and Gagne 2013)

Chap 7, 8: Scheduling. Dongkun Shin, SKKU

Announcements/Reminders

CPU Scheduling. Rab Nawaz Jadoon. Assistant Professor DCS. Pakistan. COMSATS, Lahore. Department of Computer Science

Chapter 5: CPU Scheduling

Uniprocessor Scheduling. Aim of Scheduling

Uniprocessor Scheduling. Aim of Scheduling. Types of Scheduling. Long-Term Scheduling. Chapter 9. Response time Throughput Processor efficiency

COSC243 Part 2: Operating Systems

Chapter 6: CPU Scheduling. Operating System Concepts 9 th Edition

Practice Exercises 305

Job Scheduling. CS170 Fall 2018

Announcements. Reading. Project #1 due in 1 week at 5:00 pm Scheduling Chapter 6 (6 th ed) or Chapter 5 (8 th ed) CMSC 412 S14 (lect 5)

Operating Systems. Process scheduling. Thomas Ropars.

CSCE Operating Systems Scheduling. Qiang Zeng, Ph.D. Fall 2018

Scheduling. CSC400 - Operating Systems. 7: Scheduling. J. Sumey. one of the main tasks of an OS. the scheduler / dispatcher

Scheduling. The Basics

Computer Systems Laboratory Sungkyunkwan University

Chapter 6: CPU Scheduling

ALL the assignments (A1, A2, A3) and Projects (P0, P1, P2) we have done so far.

Advanced Operating Systems (CS 202) Scheduling (1)

Last class: Today: CPU Scheduling. CPU Scheduling Algorithms and Systems

Process Scheduling Part 2

Ch 4 : CPU scheduling

CSC Operating Systems Spring Lecture - XII Midterm Review. Tevfik Ko!ar. Louisiana State University. March 4 th, 2008.

CPU Scheduling: Objectives

Scheduling. Today. Next Time Process interaction & communication

Uniprocessor Scheduling. Basic Concepts Scheduling Criteria Scheduling Algorithms. Three level scheduling

CHAPTER 2: PROCESS MANAGEMENT

Unit 3 : Process Management

CSE 4/521 Introduction to Operating Systems

Review. Preview. Three Level Scheduler. Scheduler. Process behavior. Effective CPU Scheduler is essential. Process Scheduling

CPU Scheduling. The scheduling problem: When do we make decision? - Have K jobs ready to run - Have N 1 CPUs - Which jobs to assign to which CPU(s)

Frequently asked questions from the previous class survey

Chapter 5 Scheduling

Example: CPU-bound process that would run for 100 quanta continuously 1, 2, 4, 8, 16, 32, 64 (only 37 required for last run) Needs only 7 swaps

CPU Scheduling: Part I ( 5, SGG) Operating Systems. Autumn CS4023

Titolo presentazione. Scheduling. sottotitolo A.Y Milano, XX mese 20XX ACSO Tutoring MSc Eng. Michele Zanella

CSE 120 Principles of Operating Systems Spring 2017

Uniprocessor Scheduling

CPU Scheduling. The scheduling problem: When do we make decision? - Have K jobs ready to run - Have N 1 CPUs - Which jobs to assign to which CPU(s)

8th Slide Set Operating Systems

Chapter 5: CPU Scheduling

CS307: Operating Systems

CS370 Operating Systems

Chapter 5: CPU Scheduling. Operating System Concepts Essentials 8 th Edition

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

Scheduling Mar. 19, 2018

CS 318 Principles of Operating Systems

Chapter 5: Process Scheduling

Operating System Review Part

Announcements. Program #1. Reading. Due 2/15 at 5:00 pm. Finish scheduling Process Synchronization: Chapter 6 (8 th Ed) or Chapter 7 (6 th Ed)

CPU Scheduling (1) CPU Scheduling (Topic 3) CPU Scheduling (2) CPU Scheduling (3) Resources fall into two classes:

CS 326: Operating Systems. CPU Scheduling. Lecture 6

CSCI-GA Operating Systems Lecture 3: Processes and Threads -Part 2 Scheduling Hubertus Franke

CSE 120. Summer, Inter-Process Communication (IPC) Day 3. Inter-Process Communication (IPC) Scheduling Deadlock. Instructor: Neil Rhodes

Problems Kernel Scheduler User Level Scheduler Universität Karlsruhe (TU), System Architecture Group

Start of Lecture: February 10, Chapter 6: Scheduling

Assignment 3 (Due date: Thursday, 10/15/2009, in class) Part One: Provide brief answers to the following Chapter Exercises questions:

SMD149 - Operating Systems

Uniprocessor Scheduling. Chapter 9

Lecture 2 Process Management

3. CPU Scheduling. Operating System Concepts with Java 8th Edition Silberschatz, Galvin and Gagn

Processes. CS 475, Spring 2018 Concurrent & Distributed Systems

Scheduling. Scheduling 1/51

CS418 Operating Systems

Scheduling. Scheduling. Scheduling. Scheduling Criteria. Priorities. Scheduling

So far. Next: scheduling next process from Wait to Run. 1/31/08 CSE 30341: Operating Systems Principles

Transcription:

Operating Systems Lecture 2.2 - Process Scheduling Golestan University Hossein Momeni momeni@iust.ac.ir

Scheduling What is scheduling? Goals Mechanisms Scheduling on batch systems Scheduling on interactive systems Other kinds of scheduling Real-time scheduling 2

Why schedule processes? Bursts of CPU usage alternate with periods of I/O wait Some processes are CPU-bound: they don t make many I/O requests Other processes are I/O-bound and make many kernel requests CPU bound Total CPU usage Long CPU bursts Short CPU bursts Wait for I/O I/O bound 3 Time Total CPU usage

Scheduling goals All systems Fairness: give each process a fair share of the CPU Enforcement: ensure that the stated policy is carried out Balance: keep all parts of the system busy Batch systems Throughput: maximize jobs per unit time Turnaround time: minimize time users wait for jobs CPU utilization: keep the CPU as busy as possible Interactive systems Response time: respond quickly to users requests Proportionality: meet users expectations Real-time systems Meet deadlines: missing deadlines is a system failure! Predictability: same type of behavior for each time slice 4

Throughput Measuring scheduling performance Amount of work completed per second (minute, hour) Higher throughput usually means better utilized system Response time Response time is time from when a command is submitted until results are returned Can measure average, variance, minimum, maximum, Turnaround time amount of time to execute a process (from delivery to execute = waiting time for entry to memory + waiting time for entry to ready queue + run time + I/O time ) Usually not possible to optimize for all metrics with the same scheduling algorithm 5

Optimization Criteria Max CPU utilization Max throughput Min turnaround time Min waiting time Min response time 6

Context Switch When CPU switches to another process, the system must save the state of the old process and load the saved state for the new process Context-switch time is overhead; the system does no useful work while switching 7

Terminology: Preemptive vs. non-preemptive Preemptive: A Process can be suspended and resumed Non-preemptive: A process runs until it voluntarily gives up the CPU (waiting on I/O or terminate). Most modern OSs use preemptive CPU scheduling, implemented via timer interrupts. Non-preemptive is used when suspending a process is impossible or very expensive: e.g., can t replace a flight crew in middle of flight. 8

Scheduling type: I/O Scheduling Short time scheduling Switch Ready to Running Long time scheduling Switch New to Ready Mid time scheduling Switch Waiting to Ready 9

Scheduling Policies Batch systems: First Come First Served Shorted Job First Shortest Remaining Time Next Interactive systems: Round Robin Priority Scheduling Multiple Queues Shortest Process Next Guaranteed Scheduling Lottery Scheduling Fair-share Scheduling Real-time systems: Static vs. dynamic 10

First Come, First Served (FCFS) Current job queue 4 3 6 3 A B C D FCFS scheduler Execution order 4 3 6 3 A B C D Goal: do jobs in the order they arrive Fair in the same way a bank teller line is fair Privilege: Simple algorithm! Fairness, No Starvation, low Overhead Problem: long jobs delay every job after them Many processes may wait for a single long job Priority is not supported High waiting time and TAT Not suitable for I/O bound process 11

Shortest Job First (SJF) B Current job queue 4 3 6 3 A B C D SJF scheduler Execution order 3 3 4 6 D Commensurate with Batch Systems A C Goal: do the shortest job first Short jobs complete first Long jobs delay every job after them Jobs sorted in increasing order of execution time Ordering of ties doesn t matter Advantages: Minimum TAT and Waiting Time Low overhead Disadvantages: Job Execution Time Estimation Starvation for long job 12

Shortest Remaining Time First (SRTF) B Current job queue 4 3 6 3 A B C D SJF scheduler Execution order 3 3 4 6 D A C Shortest Remaining Time First (SRTF): preemptive form of SJF Problem: how does the scheduler know how long a job will take? Advantages: Minimum TAT and Waiting Time Disadvantages: Job Execution Time Estimation Starvation for long job Commensurate with Batch Systems 13

Highest Response Ration Next (HRRN) Priority Non-preemptive Aging Response Ratio= (waiting time + CBT)/CBT Advantages: Not bad Waiting time and TAT No Starvation Fairness Low overhead Disadvantage: Estimation Increase cost 14

Round Robin (RR) scheduling Preemptive Give each process a fixed Time Slice (quantum) Rotate through ready processes Each process makes some progress No starvation, Fairness, Simple Context switching overhead High RT an WT Useful for CPU bound What s a good quantum? Too short: many process switches hurt efficiency Too long: poor response to interactive requests Typical length: 10 50 ms E D C B A A B C D E Time Commensurate with Interactive Systems 15

Example: Quantum time: 20 ms Context switch time: 5 ms Overhead cost time: 5/25 = 20% Quantum time: 100 ms Context switch time: 5 ms Overhead cost time: 5/105 < 5% Short Quantum: Low performance Long Quantum: High performance & bad response time 16

Priority scheduling Assign a priority to each process Ready process with highest priority allowed to run Running process may be interrupted after its quantum expires Priorities may be assigned dynamically Reduced when a process uses CPU time Increased when a process waits for I/O (may be set priority to 1/f, f is used time in last quantum) Often, processes grouped into multiple queues based on priority, and run roundrobin per queue High Ready processes Priority 4 Priority 3 Priority 2 Priority 1 Low Commensurate with Interactive Systems Problem Starvation low priority processes may never execute Solution Aging as time progresses increase the priority of the process 17

Multilevel Queue Ready queue is partitioned into separate queues Each queue has its own scheduling algorithm RR FCFS Scheduling must be done between the queues 18

Multilevel Queue Scheduling 19

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 (RR, FCFS) method used to determine when to upgrade a process States of process at end of execution in a queue: Terminate I/O and the Upgrade Not complete and Downgrade 20

Multilevel Feedback Queues 21

Lottery scheduling Give processes tickets for CPU time More tickets => higher share of CPU Each quantum, pick a ticket at random If there are n tickets, pick a number from 1 to n Process holding the ticket gets to run for a quantum(1/n) Over the long run, each process gets the CPU m/n of the time if the process has m of the n existing tickets Tickets can be transferred Cooperating processes can exchange tickets Clients can transfer tickets to server so it can have a higher priority 22

Scheduling in Real-Time Systems Schedulable real-time system Given m periodic events event i occurs within period P i and requires C i seconds Then the load can only be handled if m C i 1 i 1 P i 23

Scheduling user-level threads Runtime system picks a thread Process A Kernel picks a process Run-time system Thread table Process B Process table Possible scheduling of user-level threads 50-msec process quantum threads run 5 msec/cpu burst Kernel picks a process to run next Run-time system (at user level) schedules threads Run each thread for less than process quantum Example: processes get 50ms each, threads get 5ms each Example schedule: A1,A2,A3,A1,B1,B3,B2,B3 Not possible: A1,A2,B1,B2,A3,B3,A2,B1 24

Scheduling kernel-level threads Process A Kernel picks a thread Process table Process B Thread table Kernel schedules each thread No restrictions on ordering May be more difficult for each process to specify priorities Example schedule: A1,A2,A3,A1,B1,B3,B2,B3 Also possible: A1,A2,B1,B2,A3,B3,A2,B1 25