Concurrency and Threading: CPU Scheduling

Slides:



Advertisements
Similar presentations
Operating Systems CPU Scheduling. Agenda for Today What is Scheduler and its types Short-term scheduler Dispatcher Reasons for invoking scheduler Optimization.
Advertisements

Chapter 3: CPU Scheduling
CS 311 – Lecture 23 Outline Kernel – Process subsystem Process scheduling Scheduling algorithms User mode and kernel mode Lecture 231CS Operating.
Scheduling in Batch Systems
Chapter 6: CPU Scheduling
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-3 CPU Scheduling Department of Computer Science and Software Engineering.
CSC 360- Instructor: K. Wu CPU Scheduling. CSC 360- Instructor: K. Wu Agenda 1.What is CPU scheduling? 2.CPU burst distribution 3.CPU scheduler and dispatcher.
CPU Scheduling Introduction to Operating Systems: Module 13.
Scheduling. Alternating Sequence of CPU And I/O Bursts.
CPU Scheduling CSCI 444/544 Operating Systems Fall 2008.
Lecture 7: Scheduling preemptive/non-preemptive scheduler CPU bursts
Processor Scheduling Hank Levy. 22/4/2016 Goals for Multiprogramming In a multiprogramming system, we try to increase utilization and thruput by overlapping.
Lecture Topics: 11/15 CPU scheduling: –Scheduling goals and algorithms.
1 CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling.
Operating Systems Scheduling. Scheduling Short term scheduler (CPU Scheduler) –Whenever the CPU becomes idle, a process must be selected for execution.
Lecture 4 CPU scheduling. Basic Concepts Single Process  one process at a time Maximum CPU utilization obtained with multiprogramming CPU idle :waiting.
CPU scheduling.  Single Process  one process at a time  Maximum CPU utilization obtained with multiprogramming  CPU idle :waiting time is wasted 2.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
OPERATING SYSTEMS CS 3502 Fall 2017
CPU SCHEDULING.
Dan C. Marinescu Office: HEC 439 B. Office hours: M, Wd 3 – 4:30 PM.
Chapter 5a: CPU Scheduling
Networks and Operating Systems: Exercise Session 2
CPU Scheduling Shmuel Wimer prepared and instructed by
April 6, 2001 Gary Kimura Lecture #6 April 6, 2001
CPU Scheduling Chapter 5.
Operating Systems Processes Scheduling.
Uniprocessor Scheduling
Chapter 2.2 : Process Scheduling
CPU scheduling 6. Schedulers, CPU Scheduling 6.1. Schedulers
Process Scheduling B.Ramamurthy 9/16/2018.
Scheduling (Priority Based)
CPU Scheduling.
Chapter 6: CPU Scheduling
Chapter 6: CPU Scheduling
Chapter 6: CPU Scheduling
Process management Information maintained by OS for process management
CS 143A - Principles of Operating Systems
CPU Scheduling Basic Concepts Scheduling Criteria
CPU Scheduling G.Anuradha
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
Chapter 5: CPU Scheduling
Operating System Concepts
3: CPU Scheduling Basic Concepts Scheduling Criteria
Scheduling Adapted from:
Chapter5: CPU Scheduling
TDC 311 Process Scheduling.
COT 4600 Operating Systems Spring 2011
Chapter 5: CPU Scheduling
Chapter 6: CPU Scheduling
Chapter 5: CPU Scheduling
CGS 3763 Operating Systems Concepts Spring 2013
Process Scheduling Decide which process should run and for how long
Chapter 5: CPU Scheduling
CSE 451: Operating Systems Winter 2003 Lecture 6 Scheduling
Processor Scheduling Hank Levy 1.
Operating System , Fall 2000 EA101 W 9:00-10:00 F 9:00-11:00
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
CPU SCHEDULING CPU SCHEDULING.
Scheduling 21 May 2019.
Chapter 6: CPU Scheduling
Uniprocessor Scheduling
CPU Scheduling.
CPU Scheduling: Basic Concepts
Module 5: CPU Scheduling
Chapter 5: CPU Scheduling
CPU Scheduling CSE 2431: Introduction to Operating Systems
CSE 451: Operating Systems Winter 2001 Lecture 6 Scheduling
Presentation transcript:

Concurrency and Threading: CPU Scheduling Execution State of a Thread or Process Schedulers in the OS Structure of CPU Schedulers Criteria for Scheduling Scheduling Algorithms: FIFO, SJF, FP, MLFQ Multiprocessor Scheduling Concurrency and Threading: Scheduling

State of a Thread/Process CSCE 410/611 : Operating Systems State of a Thread/Process starting starting suspended ready suspended ready ready ready running running terminated suspended blocked suspended blocked blocked blocked Concurrency and Threading: Scheduling

CSCE 410/611 : Operating Systems Schedulers starting long-term (admission) scheduler short-term (CPU) scheduler suspended ready ready running terminated suspended blocked blocked medium-term (memory) scheduler Concurrency and Threading: Scheduling

CSCE 410/611 : Operating Systems Multiprogramming starting starting starting starting ready ready ready ready running running running blocked blocked Concurrency and Threading: Scheduling

CPU Bursts vs. I/O Bursts CSCE 410/611 : Operating Systems CPU Bursts vs. I/O Bursts starting short-term (CPU) scheduler CPU Burst ready ready running running I/O “Burst” blocked blocked Concurrency and Threading: Scheduling

CSCE 410/611 : Operating Systems CPU Bursts and Jobs thread starts thread terminates blocked blocked CPU burst CPU burst CPU burst Concurrency and Threading: Scheduling

CSCE 410/611 : Operating Systems CPU Bursts and Jobs thread starts thread terminates blocked blocked CPU burst CPU burst CPU burst Concurrency and Threading: Scheduling

CSCE 410/611 : Operating Systems CPU Bursts and Jobs job “starts” job “terminates” “Job” thread starts thread terminates blocked blocked CPU burst CPU burst CPU burst Concurrency and Threading: Scheduling

Scheduling Decisions Decision: “Who is going to use the CPU next?!” 4 2 ready running 3 1 non-preemptive blocked preemptive Scheduling decision points: 1. The running thread changes from running to blocked (current CPU burst of that thread is over). 2. The running thread terminates. 3. A blocked thread becomes ready (new CPU burst of that thread begins). 4. The current thread changes from running to ready . Concurrency and Threading: Scheduling

Structure of a Scheduling Subsystem CSCE 410/611 : Operating Systems Structure of a Scheduling Subsystem ready threads TCB ready queue scheduling subsystem CPU Scheduler Dispatcher select thread start new thread ? Concurrency and Threading: Scheduling

What Is a Good Scheduler? Criteria CSCE 410/611 : Operating Systems What Is a Good Scheduler? Criteria User oriented: Response time : time interval from start of job to first response Normalized response time: ratio of response time to execution time Waiting time : sum of periods spent waiting in ready queue System oriented: CPU utilization : percentage of time CPU is busy Throughput : number of jobs completed per time unit Concurrency and Threading: Scheduling

What Is a Good Scheduler? Criteria CSCE 410/611 : Operating Systems What Is a Good Scheduler? Criteria Any good scheduler should: maximize CPU utilization and throughput minimize waiting time, response time Huh? maximum/minimum values? average values? variance? Concurrency and Threading: Scheduling

Scheduling Algorithms CSCE 410/611 : Operating Systems Scheduling Algorithms FCFS : First-come-first-served SPN: Shortest Process Next Priority scheduling RR : Round-Robin MLFQ: Multilevel Feedback Queue Scheduling Multiprocessor scheduling Concurrency and Threading: Scheduling

Common Structure of a Scheduler CSCE 410/611 : Operating Systems Common Structure of a Scheduler ready queue “priority list” new jobs CPU Concurrency and Threading: Scheduling

First-Come-First-Served (FCFS/FIFO) CSCE 410/611 : Operating Systems First-Come-First-Served (FCFS/FIFO) ready queue TCB head tail new jobs CPU CPU Cons: long average and worst-case waiting times poor dynamic behavior (convoy effect) Pros: very simple Concurrency and Threading: Scheduling

CSCE 410/611 : Operating Systems Shortest-Job-First ready queue new jobs longest jobs shortest jobs CPU CPU TCB Whenever CPU is idle, pick thread with shortest next CPU burst. Pros: minimizes average waiting times Cons: Starvation of threads with long CPU bursts. How to determine length of next CPU burst?! Concurrency and Threading: Scheduling

SJF Minimizes Average Waiting Time CSCE 410/611 : Operating Systems SJF Minimizes Average Waiting Time Provably optimal! Proof: swapping of jobs Plong Plong Pshort Pshort Pshort dW = tshort - tlong < 0 Plong Example: 6 8 12 4 W = 6+18+26 = 50 12 8 6 8 12 4 12 4 W = 6+14+26 = 46 6 8 12 4 8 4 W = 6+14+18 = 38 6 8 12 4 6 4 W = 6+10+18 = 34 6 8 12 4 W = 4+10+18 = 32 Concurrency and Threading: Scheduling

Fixed-Priority Scheduler CSCE 410/611 : Operating Systems Fixed-Priority Scheduler ready queue new jobs low priority high priority CPU CPU TCB Whenever CPU is idle, pick thread with highest priority. Cons: Starvation of low-priority threads Priority: thread/process class urgency Concurrency and Threading: Scheduling

Fixed-Priority Scheduler CSCE 410/611 : Operating Systems Fixed-Priority Scheduler ready queue new jobs low priority high priority CPU CPU TCB Whenever CPU is idle, pick thread with highest priority. Cons: Starvation of low-priority threads Priority: thread/process class urgency Solution: Aging: increase priority over time Concurrency and Threading: Scheduling

Fixed Priority Scheduling (implementation) CSCE 410/611 : Operating Systems Fixed Priority Scheduling (implementation) Conceptually Priority Queues q=f(p) priority queue priority low priority CPU low priority high priority CPU (compare priorities) Selector (compare priorities) Selector Array of FIFO queues! high priority Concurrency and Threading: Scheduling

CSCE 410/611 : Operating Systems Round-Robin go back to end of queue! FIFO with preemption after time quantum Popular method for time sharing Choice of time quantum: large: FCFS small: “Processor sharing” Time quantum also defines context-switching overhead FIFO queue time quantum CPU CPU terminate Concurrency and Threading: Scheduling

Multilevel Feedback Queue Scheduling CSCE 410/611 : Operating Systems (conceptually!) low priority RR (quantum=2ms) RR (quantum=4ms) RR (quantum=8ms) FIFO (RR with quantum infinity) FIFO FIFO aging demotion (compare priorities) Selector FIFO FIFO high priority CPU Concurrency and Threading: Scheduling

Multilevel Feedback Queue Scheduling CSCE 410/611 : Operating Systems (conceptually!) low priority RR (quantum=2ms) RR (quantum=4ms) RR (quantum=8ms) FIFO (RR with quantum infinity) FIFO FIFO aging (compare priorities) Selector FIFO FIFO high priority CPU CPU demotion! Concurrency and Threading: Scheduling

Dynamic Multiprocessor Scheduling CSCE 410/611 : Operating Systems Dynamic Multiprocessor Scheduling global scheduler CPU ready queue CPU new jobs CPU CPU CPU Concurrency and Threading: Scheduling

Static Multiprocessor Scheduling CSCE 410/611 : Operating Systems Static Multiprocessor Scheduling local scheduler Partition ready queue CPU ready queue thread partitioning CPU new threads ready queue CPU ready queue CPU Concurrency and Threading: Scheduling

CPU Scheduling: Summary Execution State of a Thread or Process Schedulers in the OS Structure of Schedulers Criteria for Scheduling Scheduling Algorithms: FIFO, SJF, FP, MLFQ Multiprocessor Scheduling Concurrency and Threading: Scheduling