Operating Systems. III. Scheduling. http://soc.eurecom.fr/os/



Similar documents
Scheduling. Yücel Saygın. These slides are based on your text book and on the slides prepared by Andrew S. Tanenbaum

CPU Scheduling. CPU Scheduling

CPU Scheduling Outline

ICS Principles of Operating Systems

Deciding which process to run. (Deciding which thread to run) Deciding how long the chosen process can run

CPU Scheduling. Basic Concepts. Basic Concepts (2) Basic Concepts Scheduling Criteria Scheduling Algorithms Batch systems Interactive systems

Scheduling 0 : Levels. High level scheduling: Medium level scheduling: Low level scheduling

Announcements. Basic Concepts. Histogram of Typical CPU- Burst Times. Dispatcher. CPU Scheduler. Burst Cycle. Reading

Objectives. Chapter 5: CPU Scheduling. CPU Scheduler. Non-preemptive and preemptive. Dispatcher. Alternating Sequence of CPU And I/O Bursts

W4118 Operating Systems. Instructor: Junfeng Yang

Chapter 5 Process Scheduling

Operating Systems Concepts: Chapter 7: Scheduling Strategies

Scheduling. Scheduling. Scheduling levels. Decision to switch the running process can take place under the following circumstances:

Processor Scheduling. Queues Recall OS maintains various queues

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

OPERATING SYSTEMS SCHEDULING

/ Operating Systems I. Process Scheduling. Warren R. Carithers Rob Duncan

Objectives. Chapter 5: Process Scheduling. Chapter 5: Process Scheduling. 5.1 Basic Concepts. To introduce CPU scheduling

CPU Scheduling. Core Definitions

Process Scheduling CS 241. February 24, Copyright University of Illinois CS 241 Staff

CPU SCHEDULING (CONT D) NESTED SCHEDULING FUNCTIONS

CPU Scheduling. CSC 256/456 - Operating Systems Fall TA: Mohammad Hedayati

Road Map. Scheduling. Types of Scheduling. Scheduling. CPU Scheduling. Job Scheduling. Dickinson College Computer Science 354 Spring 2010.

Process Scheduling. Process Scheduler. Chapter 7. Context Switch. Scheduler. Selection Strategies

2. is the number of processes that are completed per time unit. A) CPU utilization B) Response time C) Turnaround time D) Throughput

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

Introduction. Scheduling. Types of scheduling. The basics

Operating Systems Lecture #6: Process Management

Operating System: Scheduling

CPU Scheduling 101. The CPU scheduler makes a sequence of moves that determines the interleaving of threads.

Job Scheduling Model

Overview of Presentation. (Greek to English dictionary) Different systems have different goals. What should CPU scheduling optimize?

CPU Scheduling. Multitasking operating systems come in two flavours: cooperative multitasking and preemptive multitasking.

Readings for this topic: Silberschatz/Galvin/Gagne Chapter 5

OS OBJECTIVE QUESTIONS

Scheduling Algorithms

Lecture Outline Overview of real-time scheduling algorithms Outline relative strengths, weaknesses

Main Points. Scheduling policy: what to do next, when there are multiple threads ready to run. Definitions. Uniprocessor policies

Real-Time Scheduling 1 / 39

Multiprocessor Scheduling and Scheduling in Linux Kernel 2.6

Operating Systems, 6 th ed. Test Bank Chapter 7

Syllabus MCA-404 Operating System - II

A Group based Time Quantum Round Robin Algorithm using Min-Max Spread Measure

A Comparative Study of CPU Scheduling Algorithms

PROCESS SCHEDULING ALGORITHMS: A REVIEW

Lecture 3 Theoretical Foundations of RTOS

Analysis of Job Scheduling Algorithms in Cloud Computing

REDUCING TIME: SCHEDULING JOB. Nisha Yadav, Nikita Chhillar, Neha jaiswal

Konzepte von Betriebssystem-Komponenten. Linux Scheduler. Valderine Kom Kenmegne Proseminar KVBK Linux Scheduler Valderine Kom

Final Report. Cluster Scheduling. Submitted by: Priti Lohani

Analysis and Comparison of CPU Scheduling Algorithms

Overview and History of Operating Systems

REAL TIME OPERATING SYSTEMS. Lesson-10:

W4118 Operating Systems. Instructor: Junfeng Yang

Scheduling policy. ULK3e 7.1. Operating Systems: Scheduling in Linux p. 1

Real-Time Operating Systems.

Linux scheduler history. We will be talking about the O(1) scheduler

Predictable response times in event-driven real-time systems

Operating System Tutorial

Operating Systems OBJECTIVES 7.1 DEFINITION. Chapter 7. Note:

CS Fall 2008 Homework 2 Solution Due September 23, 11:59PM

Operating System Aspects. Real-Time Systems. Resource Management Tasks

Linux Process Scheduling Policy

Comparison between scheduling algorithms in RTLinux and VxWorks

Completely Fair Scheduler and its tuning 1

Scheduling. Monday, November 22, 2004

Chapter 1: Introduction. What is an Operating System?

This tutorial will take you through step by step approach while learning Operating System concepts.

Module 6. Embedded System Software. Version 2 EE IIT, Kharagpur 1

Linux Scheduler. Linux Scheduler

Page 1 of 5. IS 335: Information Technology in Business Lecture Outline Operating Systems

Module 8. Industrial Embedded and Communication Systems. Version 2 EE IIT, Kharagpur 1

4. Fixed-Priority Scheduling

EECS 750: Advanced Operating Systems. 01/28 /2015 Heechul Yun

ò Paper reading assigned for next Thursday ò Lab 2 due next Friday ò What is cooperative multitasking? ò What is preemptive multitasking?

Linux O(1) CPU Scheduler. Amit Gud amit (dot) gud (at) veritas (dot) com

A Review on Load Balancing In Cloud Computing 1

Real-Time Operating Systems for MPSoCs

Weight-based Starvation-free Improvised Round-Robin (WSIRR) CPU Scheduling Algorithm

Real-Time Software. Basic Scheduling and Response-Time Analysis. René Rydhof Hansen. 21. september 2010

ò Scheduling overview, key trade-offs, etc. ò O(1) scheduler older Linux scheduler ò Today: Completely Fair Scheduler (CFS) new hotness

Thomas Fahrig Senior Developer Hypervisor Team. Hypervisor Architecture Terminology Goals Basics Details

Real- Time Scheduling

Aperiodic Task Scheduling

Real-Time Systems Prof. Dr. Rajib Mall Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Processes and Non-Preemptive Scheduling. Otto J. Anshus

Chapter 2: OS Overview

Embedded Systems. 6. Real-Time Operating Systems

Exercises : Real-time Scheduling analysis

CHAPTER 15: Operating Systems: An Overview

CS 377: Operating Systems. Outline. A review of what you ve learned, and how it applies to a real operating system. Lecture 25 - Linux Case Study

Real Time Scheduling Basic Concepts. Radek Pelánek

Operatin g Systems: Internals and Design Principle s. Chapter 10 Multiprocessor and Real-Time Scheduling Seventh Edition By William Stallings

3. Scheduling issues. Common approaches /1. Common approaches /2. Common approaches / /13 UniPD / T. Vardanega 23/01/2013. Real-Time Systems 1

Chapter 19: Real-Time Systems. Overview of Real-Time Systems. Objectives. System Characteristics. Features of Real-Time Systems

Real-Time Scheduling (Part 1) (Working Draft) Real-Time System Example

Load Balancing Scheduling with Shortest Load First

CS0206 OPERATING SYSTEMS Prerequisite CS0201, CS0203

How To Understand And Understand An Operating System In C Programming

Project No. 2: Process Scheduling in Linux Submission due: April 28, 2014, 11:59pm

Transcription:

Operating Systems Institut Mines-Telecom III. Scheduling Ludovic Apvrille ludovic.apvrille@telecom-paristech.fr Eurecom, office 470 http://soc.eurecom.fr/os/

Outline Basics of Scheduling Definitions Switching Between Processes Basics of Scheduling Definitions Switching Between Processes 2/34 Fall 2015 Institut Mines-Telecom Operating Systems - Scheduling

Definitions Switching Between Processes Scheduling Criteria All systems Fairness: Giving each process a fair share of the CPU Policy enforcement: No process should be able to overcome the rules of the system Balance: Keeping all parts of the system busy CPU utilization: Keep the CPU busy Throughput: Maximize the number of processes that are completed per time unit (hour) Turnaround Time: Minimize time between submission and termination 3/34 Fall 2015 Institut Mines-Telecom Operating Systems - Scheduling

Definitions Switching Between Processes Scheduling Criteria (Cont.) Response time: Respond to interactions as fast as possible Proportionality: Meet users expectations Real-time systems Meeting deadlines: Keep the CPU busy Predictability: Know in advance whether time constraints can always be met, or not 4/34 Fall 2015 Institut Mines-Telecom Operating Systems - Scheduling

When to Schedule Definitions Switching Between Processes At creation of a process Run parent or child? At termination of a process When a process blocks on I/O, semaphore, etc. When I/O interrupt occurs At hardware clock interrupt Non-preemptive scheduling The same process is given the CPU until it blocks or voluntarily releases the CPU Only choice if no timer is available Windows 3.1 Preemptive scheduling The same process can run only for a pre-defined time-interval The OS sets a timer to the time-interval 5/34 Fall 2015 Institut Mines-Telecom Operating Systems - Scheduling

Definitions Switching Between Processes Non-Preemptive Scheduler 6/34 Fall 2015 Institut Mines-Telecom Operating Systems - Scheduling

Preemptive Scheduler Definitions Switching Between Processes 7/34 Fall 2015 Institut Mines-Telecom Operating Systems - Scheduling

Definitions Switching Between Processes Scheduling Implementation 8/34 Fall 2015 Institut Mines-Telecom Operating Systems - Scheduling

Outline Basics of Scheduling Basics of Scheduling 9/34 Fall 2015 Institut Mines-Telecom Operating Systems - Scheduling

Presented Scheduling Algorithms For batch systems First-Come First-Served Shortest Job First Shortest Remaining Time Next Three-level scheduling For multiprocessors systems Presentation of three different approaches For interactive systems Round-Robin scheduling Priority-based scheduling Group-based scheduling Guaranteed scheduling Fair-share scheduling Lottery scheduling For RT systems Attend lectures on RTOS to know more! 10/34 Fall 2015 Institut Mines-Telecom Operating Systems - Scheduling

First-Come, First-Served (FCFS) Processes are assigned the CPU in the order they request it Single queue of ready processes Easy to program, fair Non-preemptive scheduling Example: Average Wait Time for various sets of processes Process p1 p2 p3 Duration 24 3 3 Arrival time (@) 0 0 0 Arrival order AWT=? 0+24+27 p1, p2, p3 3 = 17 p2, p3, p1 p3, p2, p1 11/34 Fall 2015 Institut Mines-Telecom Operating Systems - Scheduling

Shortest Job First (SJF) Scheduler selects the job with the shortest computation time Easy to implement Non-preemptive Optimal when processes are all ready simultaneously Minimum average time But... How to predict the next CPU burst time??? 1. Specified amount 2. Exponential average τ n+1 = αt n + (1 α)τ n τ: predicted value t: measured computation time 12/34 Fall 2015 Institut Mines-Telecom Operating Systems - Scheduling

Shortest Job First: Example Example 1: Same arrival time Process p1 p2 p3 p4 Duration 8 4 4 4 @ 0 0 0 0 Example 2: Various arrival times Process p1 p2 p3 p4 p5 Duration 2 4 1 1 1 @ 0 0 3 3 3 Algo FCFS (p1, p2, p3, p4) SJF Algo FCFS SJF AWT=? AWT=? Can you find a better scheduling??? 13/34 Fall 2015 Institut Mines-Telecom Operating Systems - Scheduling

Shortest Remaining Time Next (SRTN) Preemptive version of Shortest Job First Memo: SJF is non-preemptive Example: Comparison between SJF and SRTN Process p1 p2 Duration 10 1 @ 0 1 Algo Scheduling AWT=? 0+9 SJF p1 for 10, p2 for 1 2 = 4.5 1+0 SRTN p1 for 1, p2 for 1, p1 for 9 2 = 0.5 14/34 Fall 2015 Institut Mines-Telecom Operating Systems - Scheduling

Three-level Scheduling: Admission, CPU and Memory 15/34 Fall 2015 Institut Mines-Telecom Operating Systems - Scheduling

Three-Level Scheduling: Explanations Admission scheduler Jobs are first stored into an admission queue Jobs are then admitted in the system Memory scheduler Swap in / swap out To be avoided: Disk storage is expensive in terms of time For example, good to keep in memory 5 processes which compute 20% of their time, and store all the others processes on disk CPU scheduler In interactive systems, usually only 2 levels of scheduler Memory and CPU 16/34 Fall 2015 Institut Mines-Telecom Operating Systems - Scheduling

Round Robin (RR) Each process is assigned a time quantum If the process is still running at the end of its quantum, it is preempted Next process is assigned the CPU Widely used, easy to implement, fair How to set the value of the quantum??? Quantum too short? Quantum too long? What happens if: quantum = ɛ? quantum =? Usual quantum: 10 ms 17/34 Fall 2015 Institut Mines-Telecom Operating Systems - Scheduling

Round-Robin: Explanations 18/34 Fall 2015 Institut Mines-Telecom Operating Systems - Scheduling

Round-Robin: Example Process p1 p2 p3 Duration 24 3 3 @ 0 0 0 Quantum 4 4 4 p1 p2 p3 p1 p1 p1 p1 p1 0 4 7 10 14 18 22 26 AWT=??? 19/34 Fall 2015 Institut Mines-Telecom Operating Systems - Scheduling

Priority-Based Scheduling Limitations of RR RR assumes all processes are of equal importance For example, sending of an email vs. playing music Priority-based scheduling: Priorities are assigned to processes Static priority or dynamic priority The process with the higher priority (may be the lower value) is chosen RR between processes of the same priority 20/34 Fall 2015 Institut Mines-Telecom Operating Systems - Scheduling

Priority-Based Scheduling: Dynamic Priorities Priorities might be re-evaluated Avoids high-priority processes to jeopardize the CPU (starvation of low-priority processes) For example, priority can be set to priority n+1 = quantum t n where t n is the last computation time Example: 10 ms quantum Process used 1ms new priority = 10 Process used 5ms new priority = 2 Process used 10ms (i.e., all quantum) new priority = 1 21/34 Fall 2015 Institut Mines-Telecom Operating Systems - Scheduling

Priority-Based Scheduling (Cont.) 22/34 Fall 2015 Institut Mines-Telecom Operating Systems - Scheduling

Group-based Scheduling policy is applied according to groups of processes Example: group 1 may have a quantum of 20, and group 2 a quantum of 10 Intra-group scheduling All algorithms previously presented are applicable Inter-group scheduling Fixed-priority preemptive scheduling Highest priorities for foreground processes (interactivity) Time-slice between groups e.g., 80% for group 1, 20% for group 2 23/34 Fall 2015 Institut Mines-Telecom Operating Systems - Scheduling

Guaranteed Scheduling Special case of Group-based Idea: Give a ratio of the CPU to groups of processes For example, users are given a fraction of CPU (e.g., 1 n ) Compute the ratio between actual CPU time consumed and entitled CPU time Run the process with the lowest ratio until its ratio has moved above its closest competitor 24/34 Fall 2015 Institut Mines-Telecom Operating Systems - Scheduling

Fair-Share Scheduling Idea: Fairness between users is taken into account first For example, in RR, a user with 9 processes gets more CPU than a user with 2 Allocates a fraction of CPU to users One user = one scheduling group Other possible notions of fairness Resources, etc. 25/34 Fall 2015 Institut Mines-Telecom Operating Systems - Scheduling

Lottery Scheduling Idea: Lotto tickets are given to processes A random ticket is picked up, the winner gets a quantum of time The number of tickets received by a process is equivalent to its importance Processes can exchange tickets for cooperation Highly responsive Example A video server with three video streams at 10, 20, 25 frames / sec, respectively. Each process is given a number of tickets equals to the frame rate i.e 10, 20 and 25 26/34 Fall 2015 Institut Mines-Telecom Operating Systems - Scheduling

Multiprocessor Scheduling One scheduling queue for each processor Symmetric system A common ready-queue for all processors Asymmetric multi-processing Danger: synchronization problems because several processors could access to the scheduling data structures at the same time Only one ready-queue accessed by only one processor No synchronization issues Drawback? 27/34 Fall 2015 Institut Mines-Telecom Operating Systems - Scheduling

Outline Basics of Scheduling Windows Linux Basics of Scheduling Windows Linux 28/34 Fall 2015 Institut Mines-Telecom Operating Systems - Scheduling

Windows Linux Windows NT Scheduling Basics Priority-based preemptive round-robin scheduling Raises the priority of interactive and I/O bound processes Priority-based scheduler for the I/O queue so that background/systems programs (e.g., defragmenters) don t interfere with foreground operations (since Vista) A process runs until... It is preempted by a higher priority process It terminates Its time quantum expires (12 ms in Windows 2000) It calls a blocking system call 29/34 Fall 2015 Institut Mines-Telecom Operating Systems - Scheduling

Windows Linux Windows NT: Priority Classes 30/34 Fall 2015 Institut Mines-Telecom Operating Systems - Scheduling

Windows Linux Windows NT: Changing Classes of Processes 31/34 Fall 2015 Institut Mines-Telecom Operating Systems - Scheduling

Windows Linux Linux 2.6 Linux 2.6.22: Priority-Based Scheduler Scheduling classes Real-time processes: SCHED FIFO, SCHED RR Interactive and batch processes: SCHED OTHER, SCHED BATCH Low-priority processes: SCHED IDLE One active queue for each of the 140 priorities and for each processor Cross-CPU scheduling regularly performed (e.g., every 200 ms) SCHED OTHER Round-Robin time-sharing policy with dynamic priorities Processes running for a long time are penalized 32/34 Fall 2015 Institut Mines-Telecom Operating Systems - Scheduling

Windows Linux Linux 2.6.23... : Completely Fair Scheduler Out of balance tasks are given time to execute Out of balance task = task has not been given a fair amount of time relative to others Preemption time is variable: it depends upon the time balance of the task w.r.t. other tasks The amount of time provided to a given task is called the virtual runtime Group-based: the virtual runtime can also be computed for a whole group Priorities are used as a decay factor for the time a task is permitted to execute 33/34 Fall 2015 Institut Mines-Telecom Operating Systems - Scheduling

Android Windows Linux Roughly, the scheduler is based on the Linux one Fair scheduling approach BUT: fairness according to Groups of processes Foreground/Active, visible, service, background, empty To reclaim resources, Android may kill processes according to their running priority Foreground Visible Service Background Empty High priority Low priority 34/34 Fall 2015 Institut Mines-Telecom Operating Systems - Scheduling