Lecture 6 Page 1 CS 111 Online Non-Preemptive Scheduling Consider in the context of CPU scheduling Scheduled process runs until it yields CPU Works well.

Slides:



Advertisements
Similar presentations
CS 149: Operating Systems February 3 Class Meeting
Advertisements

Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 19 Scheduling IV.
Operating Systems CPU Scheduling. Agenda for Today What is Scheduler and its types Short-term scheduler Dispatcher Reasons for invoking scheduler Optimization.
Ceng Operating Systems Chapter 2.2 : Process Scheduling Process concept  Process scheduling Interprocess communication Deadlocks Threads.
WELCOME TO THETOPPERSWAY.COM
CS 3013 & CS 502 Summer 2006 Scheduling1 The art and science of allocating the CPU and other resources to processes.
Cs238 CPU Scheduling Dr. Alan R. Davis. CPU Scheduling The objective of multiprogramming is to have some process running at all times, to maximize CPU.
What we will cover…  CPU Scheduling  Basic Concepts  Scheduling Criteria  Scheduling Algorithms  Evaluations 1-1 Lecture 4.
CS 104 Introduction to Computer Science and Graphics Problems Operating Systems (2) Process Management 10/03/2008 Yang Song (Prepared by Yang Song and.
5: CPU-Scheduling1 Jerry Breecher OPERATING SYSTEMS SCHEDULING.
Wk 2 – Scheduling 1 CS502 Spring 2006 Scheduling The art and science of allocating the CPU and other resources to processes.
1Chapter 05, Fall 2008 CPU Scheduling The CPU scheduler (sometimes called the dispatcher or short-term scheduler): Selects a process from the ready queue.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-3 CPU Scheduling Department of Computer Science and Software Engineering.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Lecture 5 Operating Systems.
OPERATING SYSTEMS CPU SCHEDULING.  Introduction to CPU scheduling Introduction to CPU scheduling  Dispatcher Dispatcher  Terms used in CPU scheduling.
Chapter 6 CPU SCHEDULING.
Scheduling CS 111 Operating System Principles Peter Reiher
1 Scheduling Processes. 2 Processes Each process has state, that includes its text and data, procedure call stack, etc. This state resides in memory.
Operating Systems Lecture Notes CPU Scheduling Matthew Dailey Some material © Silberschatz, Galvin, and Gagne, 2002.
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.
Scheduling policies for real- time embedded systems.
1 CSE451 Scheduling Autumn 2002 Gary Kimura Lecture #6 October 11, 2002.
CPU Scheduling CSCI 444/544 Operating Systems Fall 2008.
Course Title: “Operating System” Chapter No: 04 “Process Scheduling” Course Instructor: ILTAF MEHDI IT Lecturer, MIHE, Kart-i Parwan, Kabul.
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.
Lecture 7: Scheduling preemptive/non-preemptive scheduler CPU bursts
Chapter 5: Process Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Basic Concepts Maximum CPU utilization can be obtained.
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.
Lecture 6 Page 1 CS 111 Spring 2015 Scheduling CS 111 Operating Systems Peter Reiher.
ITFN 2601 Introduction to Operating Systems Lecture 4 Scheduling.
Lecture 6 Page 1 CS 111 Fall 2015 Scheduling CS 111 Operating Systems Peter Reiher.
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.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 5 CPU Scheduling Slide 1 Chapter 5 CPU Scheduling.
6.1 CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling Algorithm Evaluation.
Lecture Topics: 11/15 CPU scheduling: –Scheduling goals and algorithms.
Scheduling Algorithms : Important Aspects Minimize Response Time –Elapsed time to do an operation (job) –Response time is what the user sees Time to echo.
Lecture 12 Page 1 CS 111 Online Using Devices and Their Drivers Practical use issues Achieving good performance in driver use.
Operating Systems Scheduling. Scheduling Short term scheduler (CPU Scheduler) –Whenever the CPU becomes idle, a process must be selected for execution.
Chapter 4 CPU Scheduling. 2 Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling Algorithm Evaluation.
Lecture 4 Page 1 CS 111 Summer 2013 Scheduling CS 111 Operating Systems Peter Reiher.
Lecture 4 CPU scheduling. Basic Concepts Single Process  one process at a time Maximum CPU utilization obtained with multiprogramming CPU idle :waiting.
CPU Scheduling CS Introduction to Operating Systems.
Process Scheduling. Scheduling Strategies Scheduling strategies can broadly fall into two categories  Co-operative scheduling is where the currently.
CPU scheduling.  Single Process  one process at a time  Maximum CPU utilization obtained with multiprogramming  CPU idle :waiting time is wasted 2.
Basic Concepts Maximum CPU utilization obtained with multiprogramming
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.
1 Chapter 5: CPU Scheduling. 2 Basic Concepts Scheduling Criteria Scheduling Algorithms.
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.
Non-Preemptive Scheduling
Outline What is scheduling? What resources should we schedule?
Operating Systems Design (CS 423)
Scheduling CS 111 Operating Systems Peter Reiher
Chapter 2.2 : Process Scheduling
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
Chapter 5: CPU Scheduling
Operating System Concepts
3: CPU Scheduling Basic Concepts Scheduling Criteria
Chapter5: CPU Scheduling
Chapter 6: CPU Scheduling
CPU SCHEDULING.
CSE 451: Operating Systems Winter 2003 Lecture 6 Scheduling
Operating System , Fall 2000 EA101 W 9:00-10:00 F 9:00-11:00
Module 5: CPU Scheduling
Module 5: CPU Scheduling
CSE 451: Operating Systems Winter 2001 Lecture 6 Scheduling
Presentation transcript:

Lecture 6 Page 1 CS 111 Online Non-Preemptive Scheduling Consider in the context of CPU scheduling Scheduled process runs until it yields CPU Works well for simple systems – Small numbers of processes – With natural producer consumer relationships Good for maximizing throughput Depends on each process to voluntarily yield – A piggy process can starve others – A buggy process can lock up the entire system

Lecture 6 Page 2 CS 111 Online When Should a Process Yield? When it knows it’s not going to make progress – E.g., while waiting for I/O – Better to let someone else make progress than sit in a pointless wait loop After it has had its “fair share” of time – Which is hard to define – Since it may depend on the state of everything else in the system Can’t expect application programmers to do sophisticated things to decide

Lecture 6 Page 3 CS 111 Online Scheduling Other Resources Non-Preemptively Schedulers aren’t just for the CPU or cores They also schedule use of other system resources – Disks – Networks – At low level, busses Is non-preemptive best for each such resource? Which algorithms we will discuss make sense for each?

Lecture 6 Page 4 CS 111 Online Non-Preemptive Scheduling Algorithms First come first served Shortest job next Real time schedulers

Lecture 6 Page 5 CS 111 Online First Come First Served The simplest of all scheduling algorithms Run first process on ready queue – Until it completes or yields Then run next process on queue – Until it completes or yields Highly variable delays – Depends on process implementations All processes will eventually be served

Lecture 6 Page 6 CS 111 Online First Come First Served Example Note: Average is worse than total/5 because four other processes had to wait for the slow-poke who ran first. Total

Lecture 6 Page 7 CS 111 Online When Would First Come First Served Work Well? FCFS scheduling is very simple It may deliver very poor response time Thus it makes the most sense: 1. In batch systems, where response time is not important 2. In embedded (e.g. telephone or set-top box) systems where computations are brief and/or exist in natural producer/consumer relationships

Lecture 6 Page 8 CS 111 Online Shortest Job First Find the shortest task on ready queue – Run it until it completes or yields Find the next shortest task on ready queue – Run it until it completes or yields Yields minimum average queuing delay – This can be very good for interactive response time – But it penalizes longer jobs When is this OK? When isn’t it?

Lecture 6 Page 9 CS 111 Online Shortest Job First Example Note: Even though total time remained unchanged, reordering the processes significantly reduced the average wait time. 305 Total 1275

Lecture 6 Page 10 CS 111 Online Is Shortest Job First Practical? How can we know how long a job is going to run? – Processes predict for themselves? – The system predicts for them? How fair is SJF scheduling? – The smaller jobs will always be run first – New small jobs cut in line, ahead of older longer jobs – Will the long jobs ever run? Only if short jobs stop arriving... which could be never This is called starvation – It is caused by discriminatory scheduling

Lecture 6 Page 11 CS 111 Online What If the Prediction is Wrong? Regardless of who made it In non-preemptive system, we have little choice: – Continue running the process until it yields If prediction is wrong, the purpose of Shortest-Job- First scheduling is defeated – Response time suffers as a result Few computer systems attempt to use Shortest-Job- First scheduling – But grocery stores and banks do use it 10-item-or-less registers Simple deposit & check cashing windows Does this change if we are using preemptive scheduling?

Lecture 6 Page 12 CS 111 Online Is Starvation Really That Bad? If optimizing for response time, it may make sense to preferentially schedule shorter jobs – The long jobs are “inappropriate” for this type of system – And inconvenience many other jobs If a job is inappropriate for our system, perhaps we should refuse to run it – But making it wait for an indefinitely long period of time doesn’t sound like reasonable behavior – Especially without feedback to job’s submitter

Lecture 6 Page 13 CS 111 Online Real Time Schedulers For certain systems, some things must happen at particular times – E.g., industrial control systems – If you don’t rivet the widget before the conveyer belt moves, you have a worthless widget These systems must schedule on the basis of real-time deadlines Can be either hard or soft

Lecture 6 Page 14 CS 111 Online Hard Real Time Schedulers The system absolutely must meet its deadlines By definition, system fails if a deadline is not met – E.g., controlling a nuclear power plant... How can we ensure no missed deadlines? Typically by very, very careful analysis – Make sure no possible schedule causes a deadline to be missed – By working it out ahead of time – Then scheduler rigorously follows deadlines

Lecture 6 Page 15 CS 111 Online Ensuring Hard Deadlines Must have deep understanding of the code used in each job – You know exactly how long it will take Vital to avoid non-deterministic timings – Even if the non-deterministic mechanism usually speeds things up – You’re screwed if it ever slows them down Typically means you do things like turn off interrupts And scheduler is non-preemptive

Lecture 6 Page 16 CS 111 Online How Does a Hard Real Time System Schedule? There is usually a very carefully pre-defined schedule No actual decisions made at run time It’s all been worked out ahead of time Not necessarily using any particular algorithm The designers may have just tinkered around to make everything “fit”

Lecture 6 Page 17 CS 111 Online Soft Real Time Schedulers Highly desirable to meet your deadlines But some (or any) of them can occasionally be missed Goal of scheduler is to avoid missing deadlines – With the understanding that you might May have different classes of deadlines – Some “harder” than others Need not require quite as much analysis

Lecture 6 Page 18 CS 111 Online Soft Real Time Schedulers and Non-Preemption Not as vital that tasks run to completion to meet their deadline – Also not as predictable, since you probably did less careful analysis In particular, a new task with an earlier deadline might arrive If you don’t pre-empt, you might not be able to meet that deadline

Lecture 6 Page 19 CS 111 Online What If You Don’t Meet a Deadline? Depends on the particular type of system Might just drop the job whose deadline you missed Might allow system to fall behind Might drop some other job in the future At any rate, it will be well defined in each particular system

Lecture 6 Page 20 CS 111 Online What Algorithms Do You Use For Soft Real Time? Most common is Earliest Deadline First Each job has a deadline associated with it – Based on a common clock Keep the job queue sorted by those deadlines Whenever one job completes, pick the first one off the queue Perhaps prune the queue to remove jobs whose deadlines were missed Minimizes total lateness

Lecture 6 Page 21 CS 111 Online Periodic Scheduling for Soft Real Time Many soft real time systems have jobs coming in at predictable intervals – With predictable deadlines System must be designed so that its total amount of work doesn’t exceed capacity – Remember λ, μ, and ρ? Even so, you might still miss deadlines – Because those quantities represent averages, not instantaneous guarantees

Lecture 6 Page 22 CS 111 Online Example of a Soft Real Time Scheduler A video playing device Frames arrive – From disk or network or wherever Ideally, each frame should be rendered “on time” – To achieve highest user-perceived quality If you can’t render a frame on time, might be better to skip it entirely – Rather than fall further behind What would be the pros and cons of using hard real time for such a system, instead of soft real time?