Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Chapter 6a: CPU Scheduling.

Slides:



Advertisements
Similar presentations
Chapter 5: CPU Scheduling
Advertisements

 Basic Concepts  Scheduling Criteria  Scheduling Algorithms.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 5: CPU Scheduling.
Operating Systems Chapter 6
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 CS 3100 CPU Scheduling1. Objectives To introduce CPU scheduling, which is the basis for multiprogrammed operating systems To describe various.
CPU Scheduling Algorithms
Chapter 3: CPU Scheduling
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 5: CPU Scheduling.
CS 311 – Lecture 23 Outline Kernel – Process subsystem Process scheduling Scheduling algorithms User mode and kernel mode Lecture 231CS Operating.
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.
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
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
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
Silberschatz, Galvin, and Gagne  Applied Operating System Concepts Module 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
CS212: OPERATING SYSTEM Lecture 3: Process Scheduling 1.
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.
Silberschatz and Galvin  Operating System Concepts Module 5: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor.
Alternating Sequence of CPU And I/O Bursts. Histogram of CPU-burst Times.
CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Thread Scheduling Multiple-Processor Scheduling Operating Systems Examples Algorithm.
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.
Chapter 5: CPU Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 5: CPU Scheduling Basic Concepts Scheduling Criteria.
Chapter 5: Process Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Basic Concepts Maximum CPU utilization can be obtained.
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, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 5: CPU Scheduling.
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.
6.1 CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling Algorithm Evaluation.
Purpose of Operating System Part 2 Monil Adhikari.
1 CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling.
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 G.Anuradha Reference : Galvin. CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time.
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.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 6: CPU Scheduling.
CPU Scheduling Algorithms CSSE 332 Operating Systems Rose-Hulman Institute of Technology.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 5: CPU Scheduling.
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.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
Chapter 6: CPU Scheduling
Chapter 5a: CPU Scheduling
Chapter 6: CPU Scheduling
Chapter 6: CPU Scheduling
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
Chapter 5: CPU Scheduling
Operating System Concepts
Chapter5: CPU Scheduling
Chapter 5: CPU Scheduling
Chapter 6: CPU Scheduling
Chapter 5: CPU Scheduling
Chapter 6: CPU Scheduling
Chapter 6: CPU Scheduling
CPU Scheduling: Basic Concepts
Presentation transcript:

Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Chapter 6a: CPU Scheduling

6.2 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms

6.3 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Objectives Introduce CPU scheduling Basis for multiprogrammed operating systems Describe various CPU-scheduling algorithms Discuss evaluation criteria for selecting a CPU- scheduling algorithm

6.4 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Basic Concepts Maximum CPU utilization with multiprogramming CPU–I/O Burst Cycle Process execution = cycles of CPU execution and I/O waits CPU burst followed by I/O burst CPU bursts are main concern

6.5 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Histogram of CPU-burst Times

6.6 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition CPU Scheduler Short-term scheduler selects among processes in ready queue, allocates CPU Queue ordered in various ways Depends on algorithm

6.7 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition CPU Scheduler Scheduling decisions may take place when process: 1.Switches from running to waiting state 2.Switches from running to ready state 3.Switches from waiting to ready 4. Terminates 1 and 4 are nonpreemptive Process voluntarily yields CPU 2 and 3 are preemptive Process preempted; CPU reallocated

6.8 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Dispatcher Dispatcher gives control of CPU to process selected by short-term scheduler; this involves: Switching context Switching to user mode Jumping to proper location in user program to restart Dispatch latency – time dispatcher takes to stop one process and start another running

6.9 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms

6.10 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Scheduling Criteria CPU utilization – keep CPU busy as possible Throughput – # of processes that complete execution per time unit Turnaround time – amount of time to execute a particular process

6.11 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Scheduling Criteria Waiting time –time process has been waiting in ready queue Response time – amount of time from when request submitted until first response is produced Does not include device output

6.12 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Scheduling Algorithm Optimization Criteria Maximize CPU utilization Maximize throughput Minimize turnaround time Minimize waiting time Minimize response time

6.13 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms

6.14 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition First- Come, First-Served (FCFS) Scheduling Simplest algorithm Process that requests CPU first is allocate CPU first Easily manage by FIFO queue Process enters ready queue at tail CPU allocated to process at head Running process removed from queue Process runs to completion

6.15 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition First- Come, First-Served (FCFS) Scheduling ProcessBurst Time P 1 24 P 2 3 P 3 3 Suppose processes arrive in order: P 1, P 2, P 3 Gantt Chart for schedule: Waiting time for P 1 = 0; P 2 = 24; P 3 = 27 Average waiting time: ( )/3 = 17

6.16 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition FCFS Scheduling (Cont.) Suppose processes arrive in order: P 2, P 3, P 1 Gantt chart schedule: Waiting time for P 1 = 6; P 2 = 0 ; P 3 = 3 Average waiting time: ( )/3 = 3 Much better than previous case

6.17 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition FCFS Scheduling (Cont.) Convoy effect - short process behind long process E.g., one CPU-bound and many I/O-bound processes All I/O bound processes wait in ready queue for CPU- bound to give up CPU Lowers CPU and device utilization Compared to if shorter processes were allowed to go first

6.18 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Shortest-Job-First (SJF) Scheduling Each process knows length of next CPU burst CPU available => schedule process with smallest burst Ties scheduled in FCFS SJF is optimal – gives minimum average waiting time Difficulty: knowing length of next CPU request Could ask user Could make mathematical predictions  E.g.,

6.19 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Example of SJF ProcessAril TimeBurst Time P P P P Average waiting time = ( ) / 4 = 7

6.20 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Example of Shortest-remaining-time-first Add varying arrival times and preemption... ProcessAarri Arrival TimeTBurst Time P 1 08 P 2 14 P 3 29 P 4 35 Average waiting time = [(10-1)+(1-1)+(17-2)+5-3)]/4 = 26/4 = 6.5 msec

6.21 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Priority Scheduling Priority number associated with each process SJF => priority scheduling algorithm  Priority = inverse of next CPU burst time CPU allocated to process with highest priority E.g., smallest number = highest priority Can be Preemptive or Nonpreemptive

6.22 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Priority Scheduling Priority Scheduling may result in starvation Low priority processes may never execute Aging is possible solution Process’ priority increases with time

6.23 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Example of Priority Scheduling ProcessAarri Burst TimeTPriority P P 2 11 P 3 24 P 4 15 P 5 52 Average waiting time = 8.2 msec

6.24 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Round Robin (RR) Each process gets unit of CPU time (time quantum q), usually milliseconds After time elapsed, process is preempted, added to end of ready queue n processes in ready queue, time quantum q, Each process gets 1/n of CPU time  CPU time in chunks of at most q time units No process waits more than (n-1)q time units

6.25 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Round Robin (RR) Timer interrupts every quantum to schedule next process If process finishes before time quantum, next process starts If process not finished, added to tail of queue Performance q large  FIFO q small  q must be large with respect to context switch, otherwise overhead is too high

6.26 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Example of RR with Time Quantum = 4 Time quantum = 4 ms ProcessBurst Time P 1 24 P 2 3 P 3 3 Average wait time: 5.66 ms ( ) / 3 = 17 / 3 = 5.66

6.27 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Example of RR with Time Quantum = 4 Typically, higher average turnaround than SJF But better response time q should be large compared to context switch time q usually 10ms to 100ms, context switch < 10 µs

6.28 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Time Quantum and Context Switch Time

6.29 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Turnaround Time Varies With The Time Quantum 80% of CPU bursts should be shorter than q

6.30 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Multilevel Queue Ready queue partitioned into separate queues, e.g., foreground (interactive) background (batch) Processes cannot switch between queues Queue assignment is permanent Each queue has own scheduling algorithm, e.g., foreground – RR background – FCFS

6.31 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Multilevel Queue: Scheduling b/t Qs Fixed priority scheduling Serve all foreground then background Possibility of starvation Time slice Each queue gets certain amount of CPU time Time scheduled amongst processes, e.g.,  80% to foreground in RR  20% to background in FCFS

6.32 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Multilevel Queue Scheduling

6.33 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Multilevel Feedback Queue Processes can move between various queues Aging implemented this way Multilevel-feedback-queue scheduler defined by: Number of queues Scheduling algorithms for each queue Method to determine when to upgrade a process Method to determine when to demote a process Method to determine which queue a process will enter

6.34 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Example of Multilevel Feedback Queue Three queues Q 0 – RR; q = 8 ms Q 1 – RR; 1 = 16 ms Q 2 – FCFS

6.35 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Example of Multilevel Feedback Queue New job enters Q 0, order is FCFS If process doesn’t finish in 8 ms, moved to Q 1 Q 1 order is FCFS If job does not finish in 16 ms, moved to Q 2 If no jobs in Q 0 and Q 1, jobs in Q 2 processed FCFS