Processor Scheduling. Background. Scheduling. Scheduling

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

W4118 Operating Systems. Instructor: Junfeng Yang

CPU Scheduling. CPU Scheduling

Chapter 5 Process Scheduling

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

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

CPU Scheduling Outline

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

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

ICS Principles of Operating Systems

Operating Systems. III. Scheduling.

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

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

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

OPERATING SYSTEMS SCHEDULING

CPU Scheduling. Core Definitions

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

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

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

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

Introduction. Scheduling. Types of scheduling. The basics

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

CPU SCHEDULING (CONT D) NESTED SCHEDULING FUNCTIONS

Job Scheduling Model

Processor Scheduling. Queues Recall OS maintains various queues

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

PROCESS SCHEDULING ALGORITHMS: A REVIEW

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

Operating System: Scheduling

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

OS OBJECTIVE QUESTIONS

Operating Systems Lecture #6: Process Management

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

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

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

Scheduling Algorithms

Operating Systems Concepts: Chapter 7: Scheduling Strategies

Analysis and Comparison of CPU Scheduling Algorithms

A Comparative Study of CPU Scheduling Algorithms

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

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

Operating Systems, 6 th ed. Test Bank Chapter 7

Linux Process Scheduling Policy

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

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

Syllabus MCA-404 Operating System - II

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

Multiprocessor Scheduling and Scheduling in Linux Kernel 2.6

Common Approaches to Real-Time Scheduling

Real-Time Scheduling 1 / 39

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

REAL TIME OPERATING SYSTEMS. Lesson-18:

W4118 Operating Systems. Instructor: Junfeng Yang

A Review on Load Balancing In Cloud Computing 1

Comparison between scheduling algorithms in RTLinux and VxWorks

Lecture 3 Theoretical Foundations of RTOS

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

Scheduling. Monday, November 22, 2004

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

A LECTURE NOTE ON CSC 322 OPERATING SYSTEM I DR. S. A. SODIYA

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

Analysis of Job Scheduling Algorithms in Cloud Computing

Today. Intro to real-time scheduling Cyclic executives. Scheduling tables Frames Frame size constraints. Non-independent tasks Pros and cons

Completely Fair Scheduler and its tuning 1

Operating Systems OBJECTIVES 7.1 DEFINITION. Chapter 7. Note:

A Priority based Round Robin CPU Scheduling Algorithm for Real Time Systems

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

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

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

Performance Comparison of RTOS

Time Management II. June 5, Copyright 2008, Jason Paul Kazarian. All rights reserved.

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

Design and performance evaluation of Advanced Priority Based Dynamic Round Robin Scheduling Algorithm (APBDRR)

Dispatching Domains for Multiprocessor Platforms and their Representation in Ada

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

Linux Block I/O Scheduling. Aaron Carroll December 22, 2007

Operating System Tutorial

Final Report. Cluster Scheduling. Submitted by: Priti Lohani

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

4. Fixed-Priority Scheduling

Task Attribute-Based Scheduling - Extending Ada s Support for Scheduling

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

Exercises : Real-time Scheduling analysis

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

Real-time scheduling algorithms, task visualization

Periodic Task Scheduling

Convenience: An OS makes a computer more convenient to use. Efficiency: An OS allows the computer system resources to be used in an efficient manner.

I/O Management. General Computer Architecture. Goals for I/O. Levels of I/O. Naming. I/O Management. COMP755 Advanced Operating Systems 1

General Overview of Shared-Memory Multiprocessor Systems

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

Predictable response times in event-driven real-time systems

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

Aperiodic Task Scheduling

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

Load Balancing Scheduling with Shortest Load First

Efficiency of Batch Operating Systems

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

218 Chapter 5 CPU Scheduling

The International Journal Of Science & Technoledge (ISSN X)

REAL TIME OPERATING SYSTEMS. Lesson-10:

Transcription:

Background Processor Scheduling The previous lecture introduced the basics of concurrency Processes and threads Definition, representation, management We now understand how a programmer can spawn concurrent computations The OS now needs to partition one of the central resources, the CPU, between these concurrent tasks 2 Scheduling The scheduler is the manager of the CPU resource It makes allocation decisions it chooses to run certain processes over others from the ready queue Zero threads: just loop in the idle loop One thread: just execute that thread More than one thread: now the scheduler has to make a resource allocation decision The scheduling algorithm determines how jobs are scheduled 3 Scheduling Threads alternate between performing I/O and performing computation In general, the scheduler runs: when a process switches from running to waiting when a process is created or terminated when an interrupt occurs In a non-preemptive system, the scheduler waits for a running process to explicitly block, terminate or yield In a preemptive system, the scheduler can interrupt a process that is running. New Ready Running Waiting Terminated 4

Process States New Ready Running Waiting Terminated Processes are I/O-bound when they spend most of their time in the waiting state Processes are CPU-bound when they spend their time in the ready and running states Scheduling Evaluation Metrics There are many possible quantitative criteria for evaluating a scheduling algorithm: CPU utilization: percentage of time the CPU is not idle Throughput: completed processes per time unit Turnaround time: submission to completion Waiting time: time spent on the ready queue Response time: response latency Predictability: variance in any of these measures The right metric depends on the context Time spent in each entry into the running state is called a CPU burst 5 6 Scheduling Algorithms FCFS First-come First-served (FCFS) (FIFO) Jobs are scheduled in order of arrival Non-preemptive Average waiting time can be large if small jobs wait behind long ones Scheduling Algorithms LIFO Last-In First-out (LIFO) Newly arrived jobs are placed at the head of the ready queue Improves response time for newly created threads May lead to starvation early processes may never get the CPU P 1 P 2 P 3 time 0 16 20 24 P 2 P 3 0 4 8 24 May lead to poor overlap of I/O and CPU and convoy effects P 1 7 8

Problem You work as a short-order cook A short order cook has to cook food for customers as they come in and specify which dish they want Each dish takes a different amount of time to prepare You want to minimize the average amount of time the customers wait for their food What strategy would you use? Note: most restaurants use FCFS. Scheduling Algorithms SJF Shortest Job First (SJF) Choose the job with the shortest next CPU burst Provably optimal for minimizing average waiting time P 1 P 3 P 2 0 15 21 24 P 3 2 P 2 3 0 3 9 24 Impossible to know the length of the next CPU burst P 1 9 10 Shortest Job First Prediction Approximate the duration of the next CPU-burst from the durations of the previous bursts The past can be a good predictor of the future No need to remember entire past history Use exponential average: t n duration of the n th CPU burst? n+1 predicted duration of the (n+1) st CPU burst? n+1 =? t n + (1-? )? n where 0??? 1? determines the weight placed on past behavior Scheduling Algorithms SRTF SJF can be either preemptive or non-preemptive The distinction occurs when a new, short job arrives while the currently process has a long time left to execute Preemptive SJF is called shortest remaining time first 11 12

Priority Scheduling Round Robin Priority Scheduling Choose next job based on priority For SJF, priority = expected CPU burst Can be either preemptive or non-preemptive Starvation: jobs can wait indefinitely Solution to starvation Age processes: increase priority as a function of waiting time Round Robin (RR) Often used for timesharing Ready queue is treated as a circular queue (FIFO) Each process is given a time slice called a quantum It is run for the quantum or until it blocks RR allocates the CPU uniformly (fairly) across all participants. If average queue length is n, each participant gets 1/n As the time quantum grows, RR becomes FCFS Smaller quanta are generally desireable, because they improve response time Context switch overhead of frequent context switch 13 14 RR with 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 time. Scheduling Algorithms Multi-level Queue Scheduling Implement multiple ready queues based on job type interactive processes CPU-bound processes batch jobs system processes student programs Different queues may be scheduled using different algorithms Intra-queue CPU allocation can be either strict or proportional Classifying jobs into queues is difficult A process may have CPU-bound phases as well as interactive ones 15 16

Multilevel Queue Scheduling Highest priority System Processes Interactive Processes Batch Processes Student Processes Lowest priority Scheduling Algorithms Multi-level Feedback Queues Implement multiple ready queues Different queues may be scheduled using different algorithms Just like multilevel queue scheduling, but assignments are not static Jobs move from queue to queue based on feedback Feedback = The behavior of the job, e.g. does it require the full quantum for computation, or does it perform frequent I/O? Very general algorithm Need to select parameters for: Number of queues Scheduling algorithm within each queue When to upgrade and downgrade a job 17 18 Multilevel Feedback Queue Scheduling Real-time Scheduling Highest priority Lowest priority Quantum = 2 Quantum = 4 Quantum = 8 FCFS 19 Real-time processes have timing constraints Expressed as deadlines or rate requirements Common RT scheduling policies Rate monotonic Simple, just one scalar priority related to the periodicity of the job Priority = 1/rate Static Earliest deadline first (EDF) Dynamic but more complex Priority = deadline Both schemes require admission control to provide guarantees 20

Scheduling on a Multiprocessor Turnaround Time Varies With The Time Quantum Two alternatives based on the total number of queues: Each processor has its own separate queue All processors share a common ready-queue, and autonomously pick threads to execute from this common queue whenever they are idle (work stealing) Scheduling locally on any single processor is mostly the same as scheduling on a uniprocessor Issues: Want to keep threads local to a processor (processor affinity) Want to keep related threads together (gang-scheduling) 21 22