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

Similar documents
Last Class: Processes

Chapter 5: CPU Scheduling

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

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

CPU Scheduling Algorithms

Properties of Processes

OPERATING SYSTEMS CS3502 Spring Processor Scheduling. Chapter 5

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

Operating System Concepts Ch. 5: Scheduling

Scheduling. The Basics

Operating Systems: Quiz2 December 15, Class: No. Name:

Scheduling in the Supermarket

Chapter 6: CPU Scheduling

Scheduling of processes

Operating Systems ECE344. Ding Yuan

Advanced Operating Systems (CS 202) Scheduling (1)

Practice Exercises 305

Uniprocessor Scheduling. Aim of Scheduling

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

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

Operating Systems. Scheduling

Chapter 9. Uniprocessor Scheduling

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

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.

CS 318 Principles of Operating Systems

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)

Course Syllabus. Operating Systems

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)

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

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

CHAPTER 2: PROCESS MANAGEMENT

Chapter 5: CPU Scheduling

CS3733: Operating Systems

Job Scheduling. CS170 Fall 2018

LECTURE 3:CPU SCHEDULING

Ch 4 : CPU scheduling

8: Scheduling. Scheduling. Mark Handley

Uniprocessor Scheduling

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

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

Learning Outcomes. Scheduling. Is scheduling important? What is Scheduling? Application Behaviour. Is scheduling important?

Chap 7, 8: Scheduling. Dongkun Shin, SKKU

CS 571 Operating Systems. Midterm Review. Angelos Stavrou, George Mason University

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

CS418 Operating Systems

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

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

Chapter 5 CPU scheduling

Operating Systems (1DT020 & 1TT802)

Process Scheduling. Copyright : University of Illinois CS 241 Staff

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

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

Announcements/Reminders

COSC243 Part 2: Operating Systems

Lecture 2 Process Management

CSE 120. Fall Lecture 8: Scheduling and Deadlock. Keith Marzullo

CSE 120 Principles of Operating Systems Spring 2017

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

CS370 Operating Systems

Uniprocessor Scheduling. Chapter 9

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)

Chapter 9 Uniprocessor Scheduling

CSL373: Lecture 6 CPU Scheduling

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

Processes. CS 475, Spring 2018 Concurrent & Distributed Systems

Operating Systems. Process scheduling. Thomas Ropars.

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

Operating Systems CMPSCI 377 Spring Mark Corner University of Massachusetts Amherst

Scheduling - Overview

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

CSE 4/521 Introduction to Operating Systems

Chapter 5 Scheduling

CSE 153 Design of Operating Systems

1.1 CPU I/O Burst Cycle

Scheduling Mar. 19, 2018

CS 153 Design of Operating Systems Winter 2016

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)

CSE 120 Principles of Operating Systems

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

CS370 Operating Systems

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

Operating Systems Unit 3

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

Frequently asked questions from the previous class survey

Unit 3 : Process Management

Chapter 6: CPU 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)

Scheduling. Scheduling 1/51

Subject Name: OPERATING SYSTEMS. Subject Code: 10EC65. Prepared By: Kala H S and Remya R. Department: ECE. Date:

What s An OS? Cyclic Executive. Interrupts. Advantages Simple implementation Low overhead Very predictable

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

Processes. Overview. Processes. Process Creation. Process Creation fork() Processes. CPU scheduling. Pål Halvorsen 21/9-2005

Frequently asked questions from the previous class survey

Operating Systems Design Fall 2010 Exam 1 Review. Paul Krzyzanowski

Tasks. Task Implementation and management

CS370 Operating Systems

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

SMD149 - Operating Systems

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

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

Transcription:

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

Intended Schedule Motivation Abstract Scheduling Problem Scheduling Goals Scheduling Policies Priority Scheduling and its problems 2009 Universität Karlsruhe (TU), System Architecture Group 2

Motivation Schedules & Scheduling? Lecturer hands out intended schedule of this course which topic at what date Schools/universities etc. need schedules for their various classes, courses, i.e. course time location Furthermore, there are schedules for Trains Airlines Ships, fairies Travel agency people are experts in scheduling 2009 Universität Karlsruhe (TU), System Architecture Group 3

Motivation Example Problem Find an appropriate traffic solution for a flight to Sydney via Bahrain and Singapore Book a car and a hotel near the conference hall Scheduling has to be done Scheduling ~ planning minor or major events, e.g. elections, examinations, weddings, recipes, etc. 2009 Universität Karlsruhe (TU), System Architecture Group 4

Abstract Scheduling Problem 2009 Universität Karlsruhe (TU), System Architecture Group 5

Abstract Scheduling Problem * How to map executable units of activity (threads) to executing units (processors)? Criteria how to schedule? overall system goals or specific application constraints: Time critical threads should meet their deadlines, neither too early, nor too late Fast response to an interactive input * Simplification: Only focus on the resource CPU 2009 Universität Karlsruhe (TU), System Architecture Group 6

Abstract Scheduling Problem T1 T2 T3 T4 T5 T6? CPU 1 CPU 2 CPU 3 How to map these 6 threads to 3 CPUs? Is there an optimal schedule? As long as there is no performance measure, we can neither produce a good, nor a bad schedule 2009 Universität Karlsruhe (TU), System Architecture Group 7

Concrete Scheduling Problems In a multi-programming system n > 1 processes (KLTs) can be ready Which of these processes (KLTs) should run next? You re watching a Beatles ( ) video How to manage that network-software data stream decoding output to screen and audio is well done concurrently? Additionally, you have initiated a long running computebound job in the background. When to switch to it? In a multi-threaded application a programmer wants to influence, how her/his threads are scheduled 2009 Universität Karlsruhe (TU), System Architecture Group 8

Concrete Scheduling Problems In assignment 1 you must emulate a user-level scheduler What does a scheduler need to know to do its job? It must know the system state and each process s state, i.e. all relevant scheduling information of each candidate and each resource Related information per KLT/PULT has to be provided at user-level You have to install your own TCBs How to find a specific TCB? What information has to be provided per TCB? 2009 Universität Karlsruhe (TU), System Architecture Group 9

Goals Quantitative Qualitative 2009 Universität Karlsruhe (TU), System Architecture Group 10

Quantitative Scheduling Goals CPU Utilization When is a CPU unused? Throughput Number of completed jobs per time Response Time Turnaround Time Waiting Time Number of Deadline Violations Lateness Tardiness Real Time Problems 2009 Universität Karlsruhe (TU), System Architecture Group 11

What is included in a Waiting Time? Waiting time? 1. Time a process spends in the ready queue influenced by current load & by scheduler 2. Time a process/thread is blocked, i.e. due to missing message missing input missing resource Blocked processes/threads should not hold a CPU Kernel stores them in a separate data structure, the waiting queue(s) influenced by process or resource shortage 2009 Universität Karlsruhe (TU), System Architecture Group 12

Response/Turnaround Time Response Time t 0 t 1 t 2 t 3 Creation time Admission time Release time First instruction of the process is executed on CPU First output of the process on the monitor Completion time In practice, all these times can be different Turnaround Time 13 2009 Universität Karlsruhe (TU), System Architecture Group

Qualitative Goals Predictability Low variance in turnaround times and/or response times of a specific task System guarantees certain quality of service Fairness Few starving applications In MULTICS, when shutting down the machine, they found a 10 year old job Robustness Few system crashes The simpler the system, the more robust 2009 Universität Karlsruhe (TU), System Architecture Group 14

Policies System Environment Principle Components of Scheduling 2009 Universität Karlsruhe (TU), System Architecture Group 15

System Environment Different Systems require different scheduling policies Computer server Use budgets (due to contracts) to fulfill requirements of its clients Distinguish between high cost and low cost applications Desktop Computer Multiple interactive & batch jobs preferring interactive ones Offer foreground and background jobs Soft Real Time Distinguish inside an application mandatory and optional parts, the latter might only improve the quality of a video or audio recording, but are not necessary 2009 Universität Karlsruhe (TU), System Architecture Group 16

Characteristics of a Scheduling Policy Scheduling order: where in the ready queue(s) to place a new (or unblocked) thread Selection: which ready thread to run next Decision mode: when to execute the selection function Non preemptive Once a thread is running, it will continue until it terminates yields blocks (e.g. due to I/O or due to a wait()) Preemptive A running KLT or process is preempted when a more urgent work has to be done or a process or KLT has expired its time slice 2009 Universität Karlsruhe (TU), System Architecture Group 17

Survey on Scheduling Policies FCFS = first come first served (R)SJF = (remaining) shortest job first RR = round robin System wide constant time-slice Job (class) specific time-slice MLF = multi-level feedback Priority Static priority values Dynamic priority values needs at least estimation of execution time 2009 Universität Karlsruhe (TU), System Architecture Group 18

Why Different Scheduling Policies? Different application scenarios Different performance measures Response time Turnaround time Throughput 2009 Universität Karlsruhe (TU), System Architecture Group 19

First Come First served Ready queue: ordered according to start times Selection function: select the oldest ready thread Decision mode: non preemptive (or preemptive) Which one to chose? Remark: Many things in daily life are scheduled according to FCFS. It s quite fair, but not usable under certain circumstances. Give examples 2009 Universität Karlsruhe (TU), System Architecture Group 20

Implementation Remarks What information do you need to implement strict FCFS? Suppose your process does a blocking I/O. How to deal with this process when its I/O has finished? Do you have to preempt the currently running process? Idea: Whenever you have to fill the PCB into a queue, do it according to increasing start times, i.e. the head of the queue must be the senior 2009 Universität Karlsruhe (TU), System Architecture Group 21

Shortest Job First Ready queue: How to order? Selection function: thread with the shortest (expected) execution (burst) time Decision mode: non preemptive We need to estimate the required processing time (CPU burst time) for each thread 2009 Universität Karlsruhe (TU), System Architecture Group 22

Round Robin Ready queue: e Append each new ready entry Selection function: select first thread in ready queue Decision mode: time preemptive A non cooperative thread is allowed to run until its time slice TS ends (TS [0.1, 100]* ms) When a timer interrupt occurs, the running thread is appended to the ready queue * Depends on the application system & on the CPU speed 2009 Universität Karlsruhe (TU), System Architecture Group 23

Multilevel Feedback in CTTS 1 P R I O R I T y Terminate Terminate Terminate Selection: first thread in highest ready queue RQ 0 Decision mode: Preemptive (at least due to time slices) However, you may also add priority preemption Whenever a thread is unblocked after an I/O it is admitted to RQ 0 1 CTSS started in 1961 at MIT, used until 1973 (reused in MULTICS) 2009 Universität Karlsruhe (TU) System Architecture Group 24

Analysis: Multilevel Feedback Policy MLFB approximates SRTF: CPU bound KLTs drop like a rock (they might starve) Short-running I/O bound jobs stay near the top Scheduling must be done between the queues Fixed priority scheduling: select a KLT from RQ i, only if RQ i-1 to RQ 0 are empty Time slice: each queue has an individual TS Countermeasure = user action foiling the intent of the OS designer Put in a bunch of meaningless I/O to keep KLTs priority high Example of Othello program: insert printf s, program ran much faster 2009 Universität Karlsruhe (TU), System Architecture Group 25

Priority Scheduling Selection function: ready thread with highest priority Decision mode: non preemptive, i.e. a thread keeps on running until it cooperates (e.g. yielding) or blocks itself (e.g. initiating an I/O) or terminates Drawbacks: Danger of starvation and priority inversion Remark: Priority based scheduling is often done with preemption and with dynamic priorities 2009 Universität Karlsruhe (TU), System Architecture Group 26

Problems with Static Priorities Thread with highest priority runs on CPU What will happen when this thread is calling yield()? After a minor delay due to execution time of yield() the calling thread will run again if no other ready thread with the same or even a higher priority 2009 Universität Karlsruhe (TU), System Architecture Group 27

Further Problems with Priorities? Priority Inversion Mars pathfinder Deadlocks Mutual waiting Spin Locks Active waiting Proper mapping of priority values to KLTs or to processes 2009 Universität Karlsruhe (TU), System Architecture Group 28

Events leading to a Thread Switch yield()works fine if there are other threads with the same priority value A thread WT is calling a method of a synchronized class with an internal wait() WT waits until its partner send a notify Partner thread ST does a notify() within another method of the same synchronized class, whereby thread WT only runs if its priority is higher than the one of thread ST A thread returns or exits otherwise 2009 Universität Karlsruhe (TU), System Architecture Group 29