2.5 Scheduling. Given a multiprogramming system, there are many times when more than 1 process is waiting for the CPU (in the ready queue). Given a multiprogramming.

Slides:



Advertisements
Similar presentations
Scheduling Introduction to Scheduling
Advertisements

© 2004, D. J. Foreman 1 Scheduling & Dispatching.
CPU Scheduling Tanenbaum Ch 2.4 Silberchatz and Galvin Ch 5.
CS 149: Operating Systems February 3 Class Meeting
Operating Systems Process Scheduling (Ch 3.2, )
Chapter 5 CPU Scheduling. CPU Scheduling Topics: Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling.
Operating Systems 1 K. Salah Module 2.1: CPU Scheduling Scheduling Types Scheduling Criteria Scheduling Algorithms Performance Evaluation.
© Ibrahim Korpeoglu Bilkent University
Operating System Process Scheduling (Ch 4.2, )
Operating System I Process Scheduling. Schedulers F Short-Term –“Which process gets the CPU?” –Fast, since once per 100 ms F Long-Term (batch) –“Which.
Scheduling in Batch Systems
Job scheduling Queue discipline.
Operating Systems Process Scheduling (Ch 4.2, )
Operating System Process Scheduling (Ch 4.2, )
1Chapter 05, Fall 2008 CPU Scheduling The CPU scheduler (sometimes called the dispatcher or short-term scheduler): Selects a process from the ready queue.
Chapter 2 Processes and Threads Scheduling Classical Problems.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
Scheduling. Alternating Sequence of CPU And I/O Bursts.
CPU Scheduling CSCI 444/544 Operating Systems Fall 2008.
1 Scheduling The part of the OS that makes the choice of which process to run next is called the scheduler and the algorithm it uses is called the scheduling.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 5: CPU Scheduling.
Process A program in execution. But, What does it mean to be “in execution”?
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
2.5 Scheduling Given a multiprogramming system. Given a multiprogramming system. Many times when more than 1 process is waiting for the CPU (in the ready.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Lecture 7: CPU Scheduling Chapter 5.
Lecture 7: Scheduling preemptive/non-preemptive scheduler CPU bursts
Chapter 5: CPU Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 5: CPU Scheduling Basic Concepts Scheduling Criteria.
Operating Systems 1 K. Salah Module 2.2: CPU Scheduling Scheduling Types Scheduling Criteria Scheduling Algorithms Performance Evaluation.
1 11/29/2015 Chapter 6: CPU Scheduling l Basic Concepts l Scheduling Criteria l Scheduling Algorithms l Multiple-Processor Scheduling l Real-Time Scheduling.
Cpr E 308 Spring 2005 Process Scheduling Basic Question: Which process goes next? Personal Computers –Few processes, interactive, low response time Batch.
Lecture 6 Page 1 CS 111 Online Preemptive Scheduling Again in the context of CPU scheduling A thread or process is chosen to run It runs until either it.
ITFN 2601 Introduction to Operating Systems Lecture 4 Scheduling.
6.1 CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling Algorithm Evaluation.
CSC 322 Operating Systems Concepts Lecture - 10: by Ahmed Mumtaz Mustehsan Special Thanks To: Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
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.
OPERATING SYSTEM LESSON 7 (SCHEDULING). SCHEDULING Multiple processes are simultaneously in the ready state and if only one CPU is available, a choice.
CS333 Intro to Operating Systems Jonathan Walpole.
1 ADVANCED OPERATING SYSTEMS Lecture 7 (Week 9) Resource Management – I (Process Scheduling) by: Syed Imtiaz Ali.
TANNENBAUM SECTION 2.4, 10.3 SCHEDULING OPERATING SYSTEMS.
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.
1 Uniprocessor Scheduling Chapter 3. 2 Alternating Sequence of CPU And I/O Bursts.
Chapter 4 CPU Scheduling. 2 Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling Algorithm Evaluation.
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.
Lecture 5 Scheduling. Today CPSC Tyson Kendon Updates Assignment 1 Assignment 2 Concept Review Scheduling Processes Concepts Algorithms.
Lecturer 5: Process Scheduling Process Scheduling  Criteria & Objectives Types of Scheduling  Long term  Medium term  Short term CPU Scheduling Algorithms.
Scheduling.
INTRO TO PROCESS SCHEDULING Module 2.4 COP4600 – Operating Systems Richard Newman.
CPU Scheduling Scheduling processes (or kernel-level threads) onto the cpu is one of the most important OS functions. The cpu is an expensive resource.
Networks and Operating Systems: Exercise Session 2
Chapter 2 Scheduling.
Chapter 6: CPU Scheduling
CPU Scheduling G.Anuradha
Module 5: CPU Scheduling
Chapter5: CPU Scheduling
TDC 311 Process Scheduling.
Chapter 5: CPU Scheduling
Chapter 6: CPU Scheduling
CPU SCHEDULING.
Process Scheduling Decide which process should run and for how long
Chapter 5: CPU Scheduling
Processor Scheduling Hank Levy 1.
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
Scheduling 21 May 2019.
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
CPU Scheduling CSE 2431: Introduction to Operating Systems
Presentation transcript:

2.5 Scheduling

Given a multiprogramming system, there are many times when more than 1 process is waiting for the CPU (in the ready queue). Given a multiprogramming system, there are many times when more than 1 process is waiting for the CPU (in the ready queue). The scheduler (using a scheduling algorithm) decides which process will run next. The scheduler (using a scheduling algorithm) decides which process will run next. User satisfaction is important. User satisfaction is important.

Context switch When the CPU changes from one process to another. When the CPU changes from one process to another. Expensive operation. Expensive operation. 1. User mode to kernel mode 2. Save state of current process Registers, invalidate cache, MMU (Note: Pipeline becomes useless.) Registers, invalidate cache, MMU (Note: Pipeline becomes useless.) 3. Run scheduler Pick next process to run Pick next process to run Load state of next process Load state of next process 4. Run next process

Process behavior Types: Types: 1. I/O bound – spend most time performing I/O 2. Compute bound – spend most time performing computation 3. Mixture

When do we need to schedule? creation (before/after parent?) creation (before/after parent?) exit exit block (I/O, semaphore, sleep, wait, etc.) block (I/O, semaphore, sleep, wait, etc.) I/O interrupt/completion I/O interrupt/completion clock interrupt clock interrupt non preemptive (run until you block or “cooperate”) non preemptive (run until you block or “cooperate”) preemptive preemptive

Scheduling environments 1. Batch 2. Interactive 3. Real time

Scheduling algorithm goals (for all systems)

Scheduling algorithm goals (for batch systems)

Scheduling algorithm goals (for interactive systems)

Scheduling algorithm goals (for real-time systems)

Concepts & definitions Throughput = # of jobs completed per hour Throughput = # of jobs completed per hour

Concepts & definitions Turnaround time = avg of “start (submit) to completion” times; avg wait time Turnaround time = avg of “start (submit) to completion” times; avg wait time

Concepts & definitions CPU utilization = avg of CPU busyness CPU utilization = avg of CPU busyness

Concepts & definitions Response time = time between issuing a command and getting the result Response time = time between issuing a command and getting the result

Concepts & definitions Proportionality = user perception that “complex” things take a long time and that is fine, but “simple” things must be quick Proportionality = user perception that “complex” things take a long time and that is fine, but “simple” things must be quick

Concepts & definitions Predictability = regularity, especially important for audio and video streaming Predictability = regularity, especially important for audio and video streaming

BATCH SCHEDULING

Batch scheduling 1. First-come first-served 2. Shortest job first 3. Shortest remaining time next 4. Three-level scheduling

Batch scheduling 1. First-come first-served Simple Simple Non preemptive Non preemptive Process runs until it either blocks on I/O or finishes Process runs until it either blocks on I/O or finishes

Batch scheduling 2. Shortest job first Optimal turnaround time (when all start together) Optimal turnaround time (when all start together) Requires that we know run times a priori Requires that we know run times a priori

Batch scheduling 3. Shortest remaining time next Preemptive version of shortest job first Preemptive version of shortest job first Requires a priori information Requires a priori information When a new job arrives, its total time is compared to the current process’ remaining time. If the new job needs less time to finish, the new job is started. When a new job arrives, its total time is compared to the current process’ remaining time. If the new job needs less time to finish, the new job is started. New, short jobs get good service New, short jobs get good service

Batch scheduling 4. Three-level scheduling 1. Admission scheduler – chooses next job begin 2. Memory scheduler – which jobs are kept in memory and which jobs are swapped to disk How long swapped in or out? How long swapped in or out? How much CPU time recently? How much CPU time recently? How big is the process? How big is the process? How important is the process? How important is the process? 3. CPU scheduler – picks which runs next Degree of multiprogramming – number of processes in memory Degree of multiprogramming – number of processes in memory

INTERACTIVE SCHEDULING

Interactive scheduling 1. Round-robin scheduling 2. Priority scheduling 3. Multiple queues 4. Shortest process next 5. Guaranteed scheduling 6. Lottery scheduling 7. Fair-share scheduling

Interactive scheduling 1. Round-robin scheduling Simple, fair, widely used, preemptive Simple, fair, widely used, preemptive Quantum = time interval Quantum = time interval Process/context switch is expensive Process/context switch is expensive Too small and we waste time Too small and we waste time Too large and interactive system will appear sluggish Too large and interactive system will appear sluggish ~20-50 msec is good ~20-50 msec is good Every process has equal priority Every process has equal priority

Interactive scheduling 2. Priority scheduling Each process is assigned a priority; process with highest priority is next to run. Each process is assigned a priority; process with highest priority is next to run. Types: Types: 1. static 2. dynamic (ex. I/O bound jobs get a boost) Unix/Linux nice command Unix/Linux nice command

Interactive scheduling Ex. 4 priorities & RR w/in a priority Ex. 4 priorities & RR w/in a priority

Interactive scheduling 3. Multiple queues different Q’s for different types of jobs different Q’s for different types of jobs Ex. 4 queues for: Ex. 4 queues for: Terminal, I/O, short quantum, and long quantum Terminal, I/O, short quantum, and long quantum

Interactive scheduling 4. Shortest process next Shortest job first always produces min avg response time (for batch systems) Shortest job first always produces min avg response time (for batch systems) How do we estimate this (for interactive jobs)? How do we estimate this (for interactive jobs)?

Interactive scheduling 4. Shortest process next Shortest job first always produces min avg response time (for batch systems) Shortest job first always produces min avg response time (for batch systems) How do we estimate this (for interactive jobs)? How do we estimate this (for interactive jobs)? From recent behavior (of interactive commands, T i ) From recent behavior (of interactive commands, T i ) Example of aging (or IIR filter) Example of aging (or IIR filter) alpha near 1 implies little memory alpha near 1 implies little memory alpha near 0 implies much memory alpha near 0 implies much memory

Interactive scheduling Example of aging (or IIR filter) Example of aging (or IIR filter) alpha near 1 implies little memory alpha near 1 implies little memory alpha near 0 implies much memory alpha near 0 implies much memory How can we “increase” the “memory?” How can we “increase” the “memory?”

Interactive scheduling 5. Guaranteed scheduling Given n processes, each process should get 1/n of the CPU time Given n processes, each process should get 1/n of the CPU time Say we keep track of the actual CPU used vs. what we should receive (entitled to/deserved). Say we keep track of the actual CPU used vs. what we should receive (entitled to/deserved). K = actual / entitled K = actual / entitled K = 1  we got what we deserved K = 1  we got what we deserved K < 1  we got less than deserved K < 1  we got less than deserved K > 1  we got more than deserved K > 1  we got more than deserved Pick process w/ min K to run next Pick process w/ min K to run next

Interactive scheduling 6. Lottery scheduling Each process gets tickets; # of tickets can vary from process to process. Each process gets tickets; # of tickets can vary from process to process. If your ticket is chosen, you run next. If your ticket is chosen, you run next. Highly responsive (new process might run right away) Highly responsive (new process might run right away) Processes can cooperate (give each other their tickets) Processes can cooperate (give each other their tickets)

Interactive scheduling 7. Fair-share scheduling Consider who (user) owns the process Consider who (user) owns the process Ex. Ex. User A has 1 process User A has 1 process User B has 9 processes User B has 9 processes Should user A get 10% and user B get 90%? Should user A get 10% and user B get 90%? Or should A get 50% and B get 50% (5.6% for each of the 9 processes)? Or should A get 50% and B get 50% (5.6% for each of the 9 processes)? Latter is fair-share. Latter is fair-share.

REAL TIME SCHEDULING

Real time scheduling Time plays an essential role. Time plays an essential role. System must react w/in a fixed amount of time. System must react w/in a fixed amount of time.

Real time scheduling Categories: Categories: 1. Hard – absolute deadlines must be met 2. Soft – missing an occasional deadline is tolerable

Real time scheduling Event types: Event types: 1. Periodic = occurring at regular intervals 2. Aperiodic = occurring unpredictably

Real time scheduling Algorithm types: Algorithm types: 1. Static (before the system starts running) 2. Dynamic (scheduling decisions at run time)

Real time scheduling Given m periodic events. Given m periodic events. Event i occurs w/ period P i, and requires C i seconds of CPU time. Event i occurs w/ period P i, and requires C i seconds of CPU time. Schedulable iff: Schedulable iff: We’re basically normalizing C (event length) by P (event frequency).

Schedulable example Given periods P i = 100, 200, and 500 msec and CPU time requirements of C i = 50, 30, 100 msec Given periods P i = 100, 200, and 500 msec and CPU time requirements of C i = 50, 30, 100 msec Can we handle another event w/ P 4 =1 sec? Can we handle another event w/ P 4 =1 sec? Yes, as long as C 4 <=150 msec Yes, as long as C 4 <=150 msec

THREADS & THREAD SCHEDULING

Thread scheduling types: 1. User level 2. Kernel level

Thread scheduling 1. User level threads No clock interrupts (per thread) No clock interrupts (per thread) A compute bound thread will dominate its process but not the CPU A compute bound thread will dominate its process but not the CPU A thread can yield to other threads within the same process A thread can yield to other threads within the same process Typically round robin or priority Typically round robin or priorityTradeoffs: + Context switch from thread to thread is simpler + App specific thread scheduler can be used - If a thread blocks on I/O, the entire process (all threads) block

Thread scheduling 2. Kernel level threads Threads scheduled like processes. Threads scheduled like processes.Tradeoffs: - Context switch from thread to thread is expensive (but scheduler can make more informed choices). + A thread, blocking on I/O, doesn’t block all other threads in process.