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.

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
5: CPU-Scheduling1 Jerry Breecher OPERATING SYSTEMS SCHEDULING.
April 1, 2002 ECEN Software Engineering of Multi-Program Systems -- University of Colorado -- Scheduling 1 Process Management -- Scheduling ECEN5043.
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.
Lecture 5: Uniprocessor Scheduling
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 ©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.
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.
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.
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.
Copyright ©: Nahrstedt, Angrave, Abdelzaher
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. Given a multiprogramming system. Many times when more than 1 process is waiting for the CPU (in the ready queue). 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 Registers, invalidate cache, MMU 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: I/O bound – spend most time performing I/O I/O bound – spend most time performing I/O Compute bound – spend most time performing computation Compute bound – spend most time performing computation Mixture 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 Batch Batch Interactive Interactive Real time Real time

Scheduling algorithm goals

Concepts & definitions Throughput = # of jobs completed per hour Throughput = # of jobs completed per hour Turnaround time = avg of “start (submit) to completion” times; avg wait time Turnaround time = avg of “start (submit) to completion” times; avg wait time CPU utilization = avg of CPU busyness CPU utilization = avg of CPU busyness Response time = time between issuing a command and getting the result Response time = time between issuing a command and getting the result 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 Predictability = regularity, especially important for audio and video streaming Predictability = regularity, especially important for audio and video streaming

Batch scheduling First-come first-served First-come first-served Shortest job first Shortest job first Shortest remaining time next Shortest remaining time next Three-level scheduling Three-level scheduling

Batch scheduling First-come first-served 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 Shortest job first Shortest job first Optimal turnaround time (when all start together) Optimal turnaround time (when all start together) Requires that we know run time a priori Requires that we know run time a priori

Batch scheduling Shortest remaining time next 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 Three-level scheduling Three-level scheduling Admission scheduler – chooses next job begin Admission scheduler – chooses next job begin Memory scheduler – which jobs are kept in memory and which jobs are swapped to disk 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? Degree of multiprogramming – number of processes in memory Degree of multiprogramming – number of processes in memory CPU scheduler – picks which runs next CPU scheduler – picks which runs next

Interactive scheduling Round-robin scheduling Round-robin scheduling Priority scheduling Priority scheduling Multiple queues Multiple queues Shortest process next Shortest process next Guaranteed scheduling Guaranteed scheduling Lottery scheduling Lottery scheduling Fair-share scheduling Fair-share scheduling

Interactive scheduling Round-robin scheduling 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 Priority scheduling 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: static or dynamic (ex. I/O bound jobs get a boost) Types: static or 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 Multiple queues Multiple queues Different types Different types 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 Shortest process next 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? How do we estimate this? 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 Guaranteed scheduling 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 Lottery scheduling 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 you ticket is chosen, you run next. If you 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 Fair-share scheduling 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% or should A get 50% and B get 50% (5.6% for each of the 9 processes)? Latter is fair-share. 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)? Latter is fair-share.

Real time scheduling Time plays an essential role Time plays an essential role Must react w/in a fixed amount of time Must react w/in a fixed amount of time Categories: Categories: Hard – absolute deadlines must be met Hard – absolute deadlines must be met Soft – missing an occasional deadline is tolerable Soft – missing an occasional deadline is tolerable Event types: Event types: Periodic = occurring at regular intervals Periodic = occurring at regular intervals Aperiodic = occurring unpredictably Aperiodic = occurring unpredictably Algorithm types: Algorithm types: Static (before the system starts running) Static (before the system starts running) Dynamic (scheduling decisions at run time) 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: (basically normalizing C by P)

Schedulable example Given P i = 100, 200, and 500 msec Given P i = 100, 200, and 500 msec Given C i = 50, 30, 100 msec Given 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

Thread scheduling User level threads 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 priority + 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 Kernel level threads Kernel level threads - 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