Advanced Operating Systems (CS 202) Scheduling (1)

Similar documents
Advanced Operating Systems (CS 202) Scheduling (1) Jan, 23, 2017

CSE 120 Principles of Operating Systems Spring 2017

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

CSE 120 Principles of Operating Systems

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

Chapter 5: CPU Scheduling

CS 153 Design of Operating Systems Winter 2016

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

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

CPU Scheduling Algorithms

Processes. CS 475, Spring 2018 Concurrent & Distributed Systems

Last Class: Processes

Announcements/Reminders

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

CSE 153 Design of Operating Systems

Operating System Concepts Ch. 5: Scheduling

1.1 CPU I/O Burst Cycle

CS 318 Principles of Operating Systems

Operating Systems ECE344. Ding Yuan

Chapter 6: CPU Scheduling

Chap 7, 8: Scheduling. Dongkun Shin, SKKU

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

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

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

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

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

Operating Systems. Process scheduling. Thomas Ropars.

ECE 7650 Scalable and Secure Internet Services and Architecture ---- A Systems Perspective. Part I: Operating system overview: Processes and threads

Multi-Level Feedback Queues

CS 326: Operating Systems. CPU Scheduling. Lecture 6

Operating Systems. Scheduling

LECTURE 3:CPU SCHEDULING

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

Chapter 5 CPU scheduling

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

CHAPTER 2: PROCESS MANAGEMENT

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

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

CS370 Operating Systems

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

Course Syllabus. Operating Systems

CS370 Operating Systems

CS370 Operating Systems

Operating Systems. CPU Scheduling ENCE 360

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

Job Scheduling. CS170 Fall 2018

CSL373: Lecture 6 CPU Scheduling

Process Scheduling. Copyright : University of Illinois CS 241 Staff

8: Scheduling. Scheduling. Mark Handley

Properties of Processes

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

OPERATING SYSTEMS. UNIT II Sections A, B & D. An operating system executes a variety of programs:

OPERATING SYSTEMS CS3502 Spring Processor Scheduling. Chapter 5

Lecture 9: Midterm Review

COSC243 Part 2: Operating Systems

Computer Systems Laboratory Sungkyunkwan University

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

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 2 Process Management

Scheduling Mar. 19, 2018

Scheduling. Today. Next Time Process interaction & communication

Supplementary Materials on Multilevel Feedback Queue

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

Scheduling. The Basics

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

CS370 Operating Systems

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

CSE 120 Principles of Operating Systems

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

Chapter 5: CPU Scheduling

TDIU25: Operating Systems II. Processes, Threads and Scheduling

Operating Systems CMPSCI 377 Spring Mark Corner University of Massachusetts Amherst

Scheduling of processes

CPU Scheduling: Objectives

Unit 3 : Process Management

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

Chapter 2 Processes and Threads

CSE 120 Principles of Operating Systems

CSE 120 Principles of Operating Systems

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

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)

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

Processes Prof. James L. Frankel Harvard University. Version of 6:16 PM 10-Feb-2017 Copyright 2017, 2015 James L. Frankel. All rights reserved.

Ch 4 : CPU scheduling

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

Frequently asked questions from the previous class survey

CS3733: Operating Systems

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

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

Scheduling. Scheduling 1/51

PROCESSES & THREADS. Charles Abzug, Ph.D. Department of Computer Science James Madison University Harrisonburg, VA Charles Abzug

OS 1 st Exam Name Solution St # (Q1) (19 points) True/False. Circle the appropriate choice (there are no trick questions).

Networks and Operating Systems ( ) Chapter 3: 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)

Chapter 5: CPU Scheduling

Operating System Review Part

CS 318 Principles of Operating Systems

CS307: 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)

Operating Systems CS 323 Ms. Ines Abbes

Transcription:

Advanced Operating Systems (CS 202) Scheduling (1)

Today: CPU Scheduling 2

The Process The process is the OS abstraction for execution It is the unit of execution It is the unit of scheduling It is the dynamic execution context of a program A process is sometimes called a job or a task A process is a program in execution Programs are static entities with the potential for execution Process is the animated/active program Starts from the program, but also includes dynamic state 3 3 3

Process Address Space 0xFFFFFFFF Stack SP Dynamic Address Space Heap (Dynamic Memory Alloc) Static Data (Data Segment) Static Code (Text Segment) PC 0x00000000 4 4 4

Process State Graph Create Process New Ready I/O Done Unschedule Process Schedule Process Waiting Terminated Running I/O, Page Fault, etc. Process Exit 5 5 5

Threads Separate dual roles of a process Resource allocation unit and execution unit A thread defines a sequential execution stream within a process (PC, SP, registers) A process defines the address space, and resources (everything but threads of execution) A thread is bound to a single process Processes, however, can have multiple threads Threads become the unit of scheduling Processes are now the containers in which threads execute Processes become static, threads are the dynamic entities 6 6 6

Threads in a Process Stack (T1) Thread 1 Thread 2 Stack (T2) Stack (T3) Thread 3 Heap Static Data PC (T2) Code PC (T3) PC (T1) CSE 153 Lecture 4 Threads 7 7 7

Thread Design Space One Thread/Process One Address Space (MSDOS) One Thread/Process Many Address Spaces (Early Unix) Address Space Thread Many Threads/Process One Address Space (Pilot, Java) Many Threads/Process Many Address Spaces (Mac OS, Unix, Windows) CSE 153 Lecture 4 Threads 8 8 8

Today: CPU Scheduling Scheduler runs when we context switching among processes/threads on the ready queue What should it do? Does it matter? Making the decision on what thread to run is called scheduling What are the goals of scheduling? What are common scheduling algorithms? Lottery scheduling Scheduling activations User level vs. Kernel level scheduling of threads 9 9 9

Scheduling Right from the start of multiprogramming, scheduling was identified as a big issue CCTS and Multics developed much of the classical algorithms Scheduling is a form of resource allocation CPU is the resource Resource allocation needed for other resources too; sometimes similar algorithms apply Requires mechanisms and policy Mechanisms: Context switching, Timers, process queues, process state information, Scheduling looks at the policies: i.e., when to switch and which process/thread to run next 10 10 10

Preemptive vs. Non-preemptive scheduling In preemptive systems where we can interrupt a running job (involuntary context switch) We re interested in such schedulers In non-preemptive systems, the scheduler waits for a running job to give up CPU (voluntary context switch) Was interesting in the days of batch multiprogramming Some systems continue to use cooperative scheduling Example algorithms: RR, Shortest Job First (how to determine shortest), 11 11 11

Scheduling Goals What are some reasonable goals for a scheduler? Scheduling algorithms can have many different goals: CPU utilization Job throughput (# jobs/unit time) Response time (Avg(T ready ): avg time spent on ready queue) Fairness (or weighted fairness) Other? Non-interactive applications: Strive for job throughput, turnaround time (supercomputers) Interactive systems Strive to minimize response time for interactive jobs Mix? 12 12 12

Goals II: Avoid Resource allocation pathologies Starvation no progress due to no access to resources E.g., a high priority process always prevents a low priority process from running on the CPU One thread always beats another when acquiring a lock Priority inversion A low priority process running before a high priority one Could be a real problem, especially in real time systems Mars pathfinder: http://research.microsoft.com/enus/um/people/mbj/mars_pathfinder/authoritative_account.html Other Deadlock, livelock, convoying 13 13 13

Non-preemptive approaches Introduced just to have a baseline FIFO: schedule the processes in order of arrival Comments? Shortest Job first Comments? 14 14 14

Preemptive scheduling: Round Robin Each task gets resource for a fixed period of time (time quantum) If task doesn t complete, it goes back in line Need to pick a time quantum What if time quantum is too long? Infinite? What if time quantum is too short? One instruction? 15 15

Priority Scheduling Priority Scheduling Choose next job based on priority Airline check-in for first class passengers Can implement SJF, priority = 1/(expected CPU burst) Also can be either preemptive or non-preemptive Problem? Starvation low priority jobs can wait indefinitely Solution Age processes Increase priority as a function of waiting time Decrease priority as a function of CPU consumption 16 16 16

Combining Algorithms Scheduling algorithms can be combined Have multiple queues Use a different algorithm for each queue Move processes among queues Example: Multiple-level feedback queues (MLFQ) Multiple queues representing different job types Interactive, CPU-bound, batch, system, etc. Queues have priorities, jobs on same queue scheduled RR Jobs can move among queues based upon execution history Feedback: Switch from interactive to CPU-bound behavior 17 17 17

Multi-level Feedback Queue (MFQ) Goals: Responsiveness Low overhead Starvation freedom Some tasks are high/low priority Fairness (among equal priority tasks) Not perfect at any of them! Used in Unix (and Windows and MacOS) 18 18

MFQ 19 19

Unix Scheduler The canonical Unix scheduler uses a MLFQ 3-4 classes spanning ~170 priority levels Timesharing: first 60 priorities System: next 40 priorities Real-time: next 60 priorities Interrupt: next 10 (Solaris) Priority scheduling across queues, RR within a queue The process with the highest priority always runs Processes with the same priority are scheduled RR Processes dynamically change priority Increases over time if process blocks before end of quantum Decreases over time if process uses entire quantum 20 20 20

Linux scheduler Went through several iterations Currently CFS Fair scheduler, like stride scheduling Supersedes O(1) scheduler: emphasis on constant time scheduling regardless of overhead CFS is O(log(N)) because of red-black tree Is it really fair? What to do with multi-core scheduling? 21 21 21