Scheduling Mar. 19, 2018

Similar documents
CS370 Operating Systems

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

CPU Scheduling: Objectives

Chapter 5: CPU Scheduling

Processes. CS 475, Spring 2018 Concurrent & Distributed Systems

Properties of Processes

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

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

CS370 Operating Systems

8: Scheduling. Scheduling. Mark Handley

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

COSC243 Part 2: Operating Systems

Last Class: Processes

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.

LECTURE 3:CPU SCHEDULING

Operating System Concepts Ch. 5: Scheduling

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

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

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

Course Syllabus. Operating Systems

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

Chapter 5: CPU Scheduling

Operating Systems. Process scheduling. Thomas Ropars.

OPERATING SYSTEMS CS3502 Spring Processor Scheduling. Chapter 5

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)

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

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

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)

Process Scheduling. Copyright : University of Illinois CS 241 Staff

Chapter 5: CPU Scheduling

CS370 Operating Systems

Comp 310 Computer Systems and Organization

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

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

Advanced Operating Systems (CS 202) Scheduling (1)

Chapter 5 CPU scheduling

Scheduling. Scheduling 1/51

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

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 5: Process Scheduling

Operating Systems. CPU Scheduling ENCE 360

Scheduling in the Supermarket

Scheduling. Today. Next Time Process interaction & communication

Operating Systems. Scheduling

CS Computer Systems. Lecture 6: Process Scheduling

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

CS307: Operating Systems

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

CS3733: Operating Systems

Chap 7, 8: Scheduling. Dongkun Shin, SKKU

Operating Systems CS 323 Ms. Ines Abbes

CSL373: Lecture 6 CPU Scheduling

Chapter 6: CPU Scheduling

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

Operating Systems Unit 3

CHAPTER 2: PROCESS MANAGEMENT

Process- Concept &Process Scheduling OPERATING SYSTEMS

Scheduling. Scheduling 1/51

Lecture 17: Threads and Scheduling. Thursday, 05 Nov 2009

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

Operating Systems ECE344. Ding Yuan

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)

Ch 4 : CPU scheduling

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

Scheduling. The Basics

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

Chapter 5 Scheduling

CPU Scheduling Algorithms

SMD149 - Operating Systems

CSE 120 Principles of Operating Systems Spring 2017

Scheduling of processes

CS370 Operating Systems

Operating System Review Part

Unit 3 : Process Management

CS 318 Principles of Operating Systems

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

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

Frequently asked questions from the previous class survey

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

Announcements/Reminders

Scheduling. Multi-processing. Process Characterization. time. ...makes use of idle. COS450-F18-05-Scheduling - October 8, 2018

Multitasking and scheduling

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

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

Computer Science 4500 Operating Systems

Multi-Level Feedback Queues

Practice Exercises 305

Operating Systems Design Fall 2010 Exam 1 Review. Paul Krzyzanowski

238P: Operating Systems. Lecture 14: Process 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

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

CS 326: Operating Systems. CPU Scheduling. Lecture 6

1.1 CPU I/O Burst Cycle

Uniprocessor Scheduling

Uniprocessor Scheduling. Aim of Scheduling

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

by Maria Lima Term Paper for Professor Barrymore Warren Mercy College Division of Mathematics and Computer Information Science

Process Scheduling Part 2

Scheduling - Overview

ò mm_struct represents an address space in kernel ò task represents a thread in the kernel ò A task points to 0 or 1 mm_structs

Transcription:

15-410...Everything old is new again... Scheduling Mar. 19, 2018 Dave Eckhardt Brian Railing Roger Dannenberg 1

Outline Chapter 5 (or Chapter 7): Scheduling Scheduling-people/textbook terminology note 2 Waiting time means time spent runnable but stuck in a scheduler queue Not time waiting for the actual event to awaken you! Task means something a scheduler schedules (we say thread or sometimes runnable )

CPU-I/O Cycle Process view: 2 states Running Blocked on I/O Life Cycle: I/O (loading executable), CPU, I/O, CPU,.., CPU (exit()) System view Running Blocked on I/O Runnable (i.e. Waiting) not enough processors right now Running blocked mostly depends on program 3 How long do processes run before blocking?

CPU Burst Lengths In general Exponential fall-off in CPU burst length 120 100 80 60 40 20 0 0 4 5 10 15 20 25 30

CPU Burst Lengths CPU-bound program Batch job Long CPU bursts 120 100 80 60 40 20 0 0 5 5 10 15 20 25 30

CPU Burst Lengths I/O-bound program Copy, Data acquisition,... Tiny CPU bursts between system calls 120 100 80 60 40 20 0 0 6 5 10 15 20 25 30

Why Scheduling? What if we let a CPU-bound program run to completion? What happens to I/O-bound programs? What if we run an I/O-bound program whenever it is runnable? 7 What happens to CPU-bound programs?

Preemptive? Four opportunities to schedule A running process blocks (I/O, page fault, wait(),...) A running process exits A blocked process becomes runnable (I/O done) Other interrupt (clock) Multitasking types 8 Fully Preemptive: All four cause scheduling Cooperative : only first two

Preemptive kernel? Preemptive multitasking All four cases cause context switch Preemptive kernel All four cases cause context switch in kernel mode This is a goal of Project 3 9 System calls: interrupt disabling only when really necessary Clock interrupts should suspend system call execution So fork() should appear atomic, but not execute that way

CPU Scheduler Invoked when CPU becomes idle and/or time passes Current task blocks Clock interrupt Select next task Quickly PCB's in: FIFO, priority queue, tree,... Switch (using dispatcher ) 10 Your term may vary

Dispatcher Set down running task Save register state Update CPU usage information Store PCB in run queue Pick up designated task Activate new task's memory 11 Protection, mapping Restore register state Return to whatever the task was previously doing

Scheduling Criteria System administrator view Maximize/trade off CPU utilization ( busy-ness ) Was important when buying computers was expensive Now heat and power often cost more than silicon Throughput ( jobs per second ) Process view Minimize Turnaround time (everything, fork() to exit()) Waiting time (runnable but not running) User view (interactive processes) 15 Minimize response time (input/output latency) Predictable response time ( Why is it slow today?? )

Algorithms Don't try these at home FCFS SJF Priority Reasonable Round-Robin Multi-level (plus feedback) Multiprocessor Load balancing Processor affinity Real-time 16

FCFS- First Come, First Served Basic idea Run task until it relinquishes CPU When runnable, place at end of FIFO queue Waiting time very dependent on mix Some processes run briefly, some much longer Convoy effect N tasks each make 1 I/O request, stall (e.g., file copy) 1 task executes very long CPU burst Lather, rinse, repeat 17 All I/O tasks become runnable during this time Result: N I/O-bound tasks can't keep I/O devices busy!

SJF- Shortest Job First Basic idea Choose task with shortest next CPU burst Will give up CPU soonest, be nicest to other tasks Provably optimal Practically impossible (oh, well) 18 Minimizes average waiting time across tasks Could predict next burst length... Text suggests averaging recent burst lengths Does not present evaluation (Why not? Hmm...)

SJF- Shortest Job First Basic idea Choose task with shortest next CPU burst Will give up CPU soonest, be nicest to other tasks Provably optimal Practically impossible (oh, well) 19 Minimizes average waiting time across tasks Could predict next burst length... Text suggests averaging recent burst lengths Does not present evaluation (Why not? Hmm...) Sometimes applications can state their remaining work Harchol-Balter et al., Size-Based Scheduling to Improve Web Performance, ACM TOCS 21:2, 5/2003

Priority Basic idea Choose most important waiting task (Nomenclature: does high priority mean p=0 or p=255?) Priority assignment Static: fixed property (engineered?) Dynamic: function of task behaviour Big problem: Starvation 20 Most important task gets to run often Least important task may never run Common hack: priority ageing

Round-Robin Basic idea Run each task for a fixed time quantum When quantum expires, append to FIFO queue Fair But not provably optimal Choosing quantum length Infinite (until process does I/O) = FCFS Infinitesimal (1 instruction) = Processor sharing 21 A technical term used by theory folks Balance fairness vs. context-switch costs

True Processor Sharing CDC Peripheral Processors Memory Memory latency Long, fixed constant Every instruction has a memory operand Processor Core 22 Quantum = 1 instruction Solution: round robin

True Processor Sharing CDC Peripheral Processors Memory Memory latency Long, fixed constant Every instruction has a memory operand Processor Core 23 Quantum = 1 instruction One process running N-1 processes waiting on memory Solution: round robin

True Processor Sharing Each instruction Run when you're ready Ready when it's your turn 24 Processor Core Steady state Memory Brief computation One load or one store Sleeps process N cycles

Everything Old Is New Again Intel hyperthreading 25 Good for some application mixes Awful for others Hyperthreading Hurts Server Performance, Say Developers - ZDNet UK, 2005-11-18 Processor Core Memory N register sets M functional units Switch on long-running operations Sharing less regular Sharing illusion more lumpy

Multi-level Queue N independent process queues 26 One per priority Algorithm per-queue Priority 0 P1 P7 R. Robin Priority 1 P2 P9 P3 R. Robin Batch P4 FCFS P0

Multi-level Queue Inter-queue scheduling? Strict priority Time slicing (e.g., weighted round-robin) 27 Pri 0 runs before Pri 1, Pri 1 runs before batch every time Pri 0 gets 2 slices Pri 1 gets 1 slice Batch gets 1 slice

Multi-level Feedback Queue N queues, different quanta Block/sleep before quantum expires? Added to end of your queue ( good runnable ) Exhaust your quantum? Demoted to slower queue ( bad runnable! ) Lower priority, typically longer quantum Can you be promoted back up? Maybe I/O promotes you Maybe you age upward Popular time-sharing scheduler 28

Multiprocessor Scheduling Common assumptions Homogeneous processors (same speed) Uniform memory access (UMA) Goal: Load sharing / Load balancing 29 Easy : single global ready queue no false idleness

Multiprocessor Scheduling Common assumptions Homogeneous processors (same speed) Uniform memory access (UMA) Goal: Load sharing / Load balancing Easy : single global ready queue no false idleness But! Single global ready queue is a contention hot spot Processor Affinity : some processor may be more desirable or necessary 30 Special I/O device Fast thread switch Resuming onto most-recent CPU may find some stuff still cached 1/Nth of memory may be faster - NUMA

Scheduler Evaluation Approaches Deterministic modeling aka hand execution Queueing theory Often gives fast and useful approximations Math gets big fast Math sensitive to assumptions May be unrealistic (aka wrong ) Simulation 31 Workload model or trace-driven GIGO hazard (either way)

Real-Time Scheduling What s a computation worth? time Real Time : No (extra) value if early (or in some cases, curve just falls off fast) 32 time time time

Hard Real-Time =? Multiple definitions are used Very fast response time 10µs? No value if results are late Very costly if late Never late No value Very costly 33

Hard Real-Time Scheduling Designers must describe task requirements Worst-case execution time of instruction sequences Prove system response time Argument or automatic verifier Cannot use indeterminate-time technologies Disks... Networks... Solutions often involve 34 Simplified designs Over-engineered systems Dedicated hardware Specialized OS

Soft Real-Time Scheduling Computation still has value after deadline Think User Interface Many control systems (if the fly-by-wire system doesn t move the elevator within 50ms, probably still good to to it within 100ms) Performance is not critical (no one will die) YouTube video Skype CD-R writing software 35 Note that late packets cause audio drop-out. Resulting CD can be corrupted

Soft Real-Time Scheduling Now commonly supported in generic OS POSIX real-time extensions for Unix Priority-based scheduler Preemptible kernel implementation 36

Summary Round-robin is ok for simple cases Certainly 80% of the conceptual weight Certainly good enough for P3 Speaking of P3... Understand preemption, don't evade it Real systems Some multi-level feedback Probably some soft real-time Multi-processor scheduling is a big deal Real-Time Systems Concepts 37 Terminology: soft, hard, deadline Key issue: priority inversion (see text)