Scheduling Algorithms. Announcements Homework 1 is graded Homework 2 is on CMS Prelim is in class on 14 th March.

Slides:



Advertisements
Similar presentations
CPU Scheduling.
Advertisements

Chapter 5: CPU Scheduling
Schedulers Long-term scheduler (or job scheduler) – selects which processes should be brought into the ready queue. Short-term scheduler (or CPU scheduler)
CPU Scheduling.
Scheduling Criteria CPU utilization – keep the CPU as busy as possible (from 0% to 100%) Throughput – # of processes that complete their execution per.
CPU Scheduling Questions answered in this lecture: What is scheduling vs. allocation? What is preemptive vs. non-preemptive scheduling? What are FCFS,
Chap 5 Process Scheduling. Basic Concepts Maximum CPU utilization obtained with multiprogramming CPU–I/O Burst Cycle – Process execution consists of a.
Chapter 5 CPU Scheduling. CPU Scheduling Topics: Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling.
Operating Systems CPU Scheduling. Agenda for Today What is Scheduler and its types Short-term scheduler Dispatcher Reasons for invoking scheduler Optimization.
CPU Scheduling Algorithms
Operating Systems 1 K. Salah Module 2.1: CPU Scheduling Scheduling Types Scheduling Criteria Scheduling Algorithms Performance Evaluation.
02/06/2008CSCI 315 Operating Systems Design1 CPU Scheduling Algorithms Notice: The slides for this lecture have been largely based on those accompanying.
Scheduling in Batch Systems
Chapter 6: CPU Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 2, 2005 Chapter 6: CPU Scheduling Basic.
CPU Scheduling. Schedulers Process migrates among several queues –Device queue, job queue, ready queue Scheduler selects a process to run from these queues.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
What we will cover…  CPU Scheduling  Basic Concepts  Scheduling Criteria  Scheduling Algorithms  Evaluations 1-1 Lecture 4.
Chapter 5-CPU Scheduling
CPU Scheduling. Announcements CS 414 Homework next Wednesday, Feb 7th CS 415 initial design documents due TODAY, Friday, Feb 2nd –Project due following.
Job scheduling Queue discipline.
CPU Scheduling Prof. Sirer (dr. Willem de Bruijn) CS 4410 Cornell University.
02/11/2004CSCI 315 Operating Systems Design1 CPU Scheduling Algorithms Notice: The slides for this lecture have been largely based on those accompanying.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
Chapter 5: CPU Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 2, 2005 Basic Concepts Maximum CPU utilization.
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.
Scheduling. Alternating Sequence of CPU And I/O Bursts.
CPU Scheduling CSCI 444/544 Operating Systems Fall 2008.
Silberschatz and Galvin  Operating System Concepts Module 5: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 5: CPU Scheduling.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Lecture 7: CPU Scheduling Chapter 5.
Chapter 5: CPU Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 5: CPU Scheduling Basic Concepts Scheduling Criteria.
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.
Chapter 5: CPU Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 2, 2005 Chapter 5: CPU Scheduling Basic.
Silberschatz and Galvin  Operating System Concepts Module 5: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 5 CPU Scheduling Slide 1 Chapter 5 CPU Scheduling.
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.
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.
1 Module 5: Scheduling CPU Scheduling Scheduling Algorithms Reading: Chapter
Basic Concepts Maximum CPU utilization obtained with multiprogramming
1 Lecture 5: CPU Scheduling Operating System Fall 2006.
CPU Scheduling Algorithms CSSE 332 Operating Systems Rose-Hulman Institute of Technology.
Chapter 5: CPU Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 5: CPU Scheduling Basic Concepts Scheduling Criteria.
1 Chapter 5: CPU Scheduling. 2 Basic Concepts Scheduling Criteria Scheduling Algorithms.
CPU SCHEDULING.
CPU Scheduling.
Chapter 6: CPU Scheduling
CPU Scheduling G.Anuradha
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
Operating System Concepts
3: CPU Scheduling Basic Concepts Scheduling Criteria
Chapter5: CPU Scheduling
Chapter 5: CPU Scheduling
Chapter 6: CPU Scheduling
Outline Scheduling algorithms Multi-processor scheduling
Chapter 5: CPU Scheduling
Processor Scheduling Hank Levy 1.
Shortest-Job-First (SJR) Scheduling
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
CPU SCHEDULING CPU SCHEDULING.
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
Presentation transcript:

Scheduling Algorithms

Announcements Homework 1 is graded Homework 2 is on CMS Prelim is in class on 14 th March

Scheduling Algorithms FCFS First-come First-served (FCFS) (FIFO) –Jobs are scheduled in order of arrival –Non-preemptive Problem: –Average waiting time depends on arrival order Advantage: really simple! time P1P1 P2P2 P3P P1P1 P2P2 P3P3 048

Convoy Effect A CPU bound job will hold CPU until done, –or it causes an I/O burst rare occurrence, since the thread is CPU-bound long periods where no I/O requests issued, and CPU held –Result: poor I/O device utilization Example: one CPU bound job, many I/O bound CPU bound runs (I/O devices idle) CPU bound blocks I/O bound job(s) run, quickly block on I/O CPU bound runs again I/O completes CPU bound still runs while I/O devices idle (continues…) –Simple hack: run process whose I/O completed? What is a potential problem?

Scheduling Algorithms LIFO Last-In First-out (LIFO) –Newly arrived jobs are placed at head of ready queue –Improves response time for newly created threads Problem: –May lead to starvation – early processes may never get CPU

Problem You work as a short-order cook –Customers come in and specify which dish they want –Each dish takes a different amount of time to prepare Your goal: –minimize average time the customers wait for their food What strategy would you use ? –Note: most restaurants use FCFS.

Scheduling Algorithms: SJF Shortest Job First (SJF) –Choose the job with the shortest next CPU burst –Provably optimal for minimizing average waiting time Problem: –Impossible to know the length of the next CPU burst P1P1 P2P2 P3P P1P1 P2P2 P3P3 039 P2P2 P3P3

Scheduling Algorithms SRTF SJF can be either preemptive or non-preemptive –New, short job arrives; current process has long time to execute Preemptive SJF is called shortest remaining time first P1P1 P2P2 P3P P1P1 P3P3 P1P1 P2P

Approximate next CPU-burst duration –from the durations of the previous bursts The past can be a good predictor of the future No need to remember entire past history Use exponential average: t n duration of the n th CPU burst n+1 predicted duration of the (n+1) st CPU burst n+1 = t n + (1- ) n where 0 1 determines the weight placed on past behavior Shortest Job First Prediction

Priority Scheduling –Choose next job based on priority –For SJF, priority = expected CPU burst –Can be either preemptive or non-preemptive Problem: –Starvation: jobs can wait indefinitely Solution to starvation –Age processes: increase priority as a function of waiting time

Round Robin Round Robin (RR) –Often used for timesharing –Ready queue is treated as a circular queue (FIFO) –Each process is given a time slice called a quantum –It is run for the quantum or until it blocks –RR allocates the CPU uniformly (fairly) across participants. –If average queue length is n, each participant gets 1/n

RR with Time Quantum = 20 ProcessBurst Time P 1 53 P 2 17 P 3 68 P 4 24 The Gantt chart is: Higher average turnaround than SJF, But better response time P1P1 P2P2 P3P3 P4P4 P1P1 P3P3 P4P4 P1P1 P3P3 P3P

Turnaround Time w/ Time Quanta

RR: Choice of Time Quantum Performance depends on length of the timeslice –Context switching isnt a free operation. –If timeslice time is set too high attempting to amortize context switch cost, you get FCFS. i.e. processes will finish or block before their slice is up anyway –If its set too low youre spending all of your time context switching between threads. –Timeslice frequently set to ~100 milliseconds –Context switches typically cost < 1 millisecond Moral: Context switch is usually negligible (< 1% per timeslice) unless you context switch too frequently and lose all productivity

Scheduling Algorithms Multi-level Queue Scheduling Implement multiple ready queues based on job type –interactive processes –CPU-bound processes –batch jobs –system processes –student programs Different queues may be scheduled using different algos Intra-queue CPU allocation is either strict or proportional Problem: Classifying jobs into queues is difficult –A process may have CPU-bound phases as well as interactive ones

Multilevel Queue Scheduling System Processes Interactive Processes Batch Processes Student Processes Lowest priority Highest priority

Scheduling Algorithms Multi-level Feedback Queues Implement multiple ready queues –Different queues may be scheduled using different algorithms –Just like multilevel queue scheduling, but assignments are not static Jobs move from queue to queue based on feedback –Feedback = The behavior of the job, e.g. does it require the full quantum for computation, or does it perform frequent I/O ? Very general algorithm Need to select parameters for: –Number of queues –Scheduling algorithm within each queue –When to upgrade and downgrade a job

Multilevel Feedback Queues Quantum = 2 Quantum = 4 Quantum = 8 FCFS Lowest priority Highest priority

A Multi-level System low high priority timeslice I/O bound jobs CPU bound jobs

Thread Scheduling Since all threads share code & data segments Option 1: Ignore this fact Option 2: Gang scheduling –run all threads belonging to a process together (multiprocessor only) –if a thread needs to synchronize with another thread the other one is available and active Option 3: Two-level scheduling: –Medium level scheduler –schedule processes, and within each process, schedule threads –reduce context switching overhead and improve cache hit ratio Option 4: Space-based affinity: –assign threads to processors (multiprocessor only) –improve cache hit ratio, but can bite under low-load condition

Real-time Scheduling Real-time processes have timing constraints –Expressed as deadlines or rate requirements Common RT scheduling policies –Rate monotonic Just one scalar priority related to the periodicity of the job Priority = 1/rate Static –Earliest deadline first (EDF) Dynamic but more complex Priority = deadline Both require admission control to provide guarantees

Postscript The best schemes are adaptive. To do absolutely best wed have to predict the future. –Most current algorithms give highest priority to those that need the least! Scheduling become increasingly ad hoc over the years. –1960s papers very math heavy, now mostly tweak and see

Problem What are metrics that schedulers should optimize for ? –There are many, the right choice depends on the context Suppose: –You own an airline, have one expensive plane, and passengers waiting all around the globe –You own a sweatshop, and need to evaluate workers –You are at a restaurant, and are waiting for food –You are an efficiency expert, and are evaluating government procedures at the DMV –You are trying to find a project partner or a co-author –You own a software company that would like to deliver a product by a deadline