V0.1 CSS430 Scheduling Textbook Chapter 5 Instructor: Stephen G. Dame These slides were adapted from the OSC textbook slides (Silberschatz,

Slides:



Advertisements
Similar presentations
Scheduling Criteria CPU utilization – keep the CPU as busy as possible (from 0% to 100%) Throughput – # of processes that complete their execution per.
Advertisements

Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 17 Scheduling III.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Chapter 6a: CPU Scheduling.
 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.
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
Operating System Concepts with Java – 7 th Edition, Nov 15, 2006 Silberschatz, Galvin and Gagne ©2007 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.
Modified from Silberschatz, Galvin and Gagne ©2009 Lecture 9 Chapter 5: CPU Scheduling (cont)
CSS430 CPU Scheduling1 Textbook Ch5 These slides were compiled from the Applied OSC textbook slides (Silberschatz, Galvin, and Gagne) and the instructor’s.
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.
Silberschatz, Galvin, and Gagne  Applied Operating System Concepts Module 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 Scheduler What is the job of.
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.
CSS430 CPU Scheduling1 Textbook Ch6 These slides were compiled from the Applied OSC textbook slides (Silberschatz, Galvin, and Gagne) and the instructor’s.
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.
5.1 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Chapter 5: Process Scheduling Objectives To introduce CPU scheduling To describe various.
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.
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 ©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 6: CPU Scheduling
Module 5: CPU Scheduling
3: CPU Scheduling Basic Concepts Scheduling Criteria
Chapter5: CPU Scheduling
Chapter 5: CPU Scheduling
Chapter 6: CPU Scheduling
Chapter 5: CPU Scheduling
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
Presentation transcript:

V0.1 CSS430 Scheduling Textbook Chapter 5 Instructor: Stephen G. Dame These slides were adapted from the OSC textbook slides (Silberschatz, Galvin, and Gagne), Professor Munehiro Fukuda and the instructor’s class materials. 1 CSS430 Operating Systems : Scheduling

V0.1 CPU Scheduling Learning Objectives 2 CSS430 Operating Systems : Scheduling  Basic Concepts  Scheduling Criteria  Scheduling Algorithms (FCFS, SJF, etc.)  Thread Scheduling  Multi-Processor Scheduling  OS Examples  Algorithm Evaluation

V0.1 TermDefinition PCBProcess Control Blocks FCFSFirst-Come First-Served scheduling algorithm SJFSmallest-Job-First scheduling algorithm RRRound Robin FIFOFirst In First Out (Queue) quantumsmallest schedulable time interval (“time slice”) Foregroundinteractive processes Backgroundbatch (or system) processes PCSprocess-contention scope SCSsystem-contention scope TATTurnaround TimeGlossary 3 CSS430 Operating Systems : Scheduling

V0.1 Processes vs. Threads 4 CSS430 Operating Systems : Scheduling  Based on last class... A fine distinction between processes and threads in Linux (e.g. tasks) A fine distinction between processes and threads in Linux (e.g. tasks)  Terms (in chapter 5) used interchangeably Process scheduling Process scheduling Thread scheduling Thread scheduling  Kernel level threads being scheduled – not processes.

V0.1 CPU Scheduling Goal 5 CSS430 Operating Systems : Scheduling The main objective of multiprogramming is to maximize CPU resource utilization for a given computer environment though optimal CPU scheduling. Example Computing Environments:   System Processes   Interactive processes   Batch oriented processes

V0.1 Histogram of CPU-burst Times 6 CSS430 Operating Systems : Scheduling CPU Burst DurationTYPE OF PROGRAM SHORTI/O Bound LONGCPU Bound

V0.1 CPU-I/O Burst Cycles 7 CSS430 Operating Systems : Scheduling CPU burst wait for I/O load store add store read from file I/O burst CPU burst wait for I/O store increment index write to file I/O burst CPU burst wait for I/O load store add store read from file I/O burst CPU burst wait for I/O load store add store read from file I/O burst CPU burst wait for I/O store increment index write to file I/O burst CPU burst wait for I/O load store add store read from file I/O burst Process A Process B Cycle n Cycle n+1 Cycle n+2

V0.1 CPU Scheduler 8 CSS430 Operating Systems : Scheduling Running Waiting Ready Exit UML Process State Diagram Wait I/O Complete Interrupt Ready Queue Short-term Scheduler If only and then scheduling = non-preemptive else scheduling = preemptive 14 Process Termination PCBs

V0.1 TermDefinition CPU Utilization Typically ranges from 40% to 90% - keep the CPU as busy as possible. ThroughputNumber of processes completed per unit of time. Turnaround Time (TAT) Time of process submission to time of completion. Waiting Time Total amount of time a process spends waiting in the ready queue. Response Time Time a process takes from submission to start of response. Scheduling Criteria 9 CSS430 Operating Systems : Scheduling

V0.1 First-Come First-Served (FCFS) 10 CSS430 Operating Systems : Scheduling  Example:ProcessBurst Time P 1 24 P 2 3 P 2 3 P 3 3 P 3 3  Suppose that the processes arrive in the order: P 1, P 2, P 3  Suppose that the processes arrive in the order: P 2, P 3, P 1.  Non-preemptive scheduling  Troublesome for time-sharing systems Convoy effect short process behind long process Convoy effect short process behind long process P1P1 P3P3 P2P P1P1 P2P2 P3P Waiting time for P 1 = 0; P 2 = 24; P 3 = 27 Average waiting time: ( )/3 = 17 Waiting time for P 1 = 6; P 2 = 0 ; P 3 = 3 Average waiting time: ( )/3 = 3 The process that requests the CPU first is allocated the CPU first.

V CSS430 Operating Systems : Scheduling 2 P 4 (2) (SJF) Average waiting time = ( )/4 = 3.75 P 2 (5) P 3 (0) P 1 (9) P 3 ‘s waiting time = 0 P 4 ‘s waiting time = 2 P 2 ‘s waiting time = 5 P 1 ‘s waiting time = 9 Proces s CPU Burst Time P17 P24 P32 P43 P1P1 P2P2 P3P3 P4P4 5 (FCFS) Average waiting time = ( )/4 = Shortest-Job-First (SJF) Non-preemptive

V0.1 Shortest-Job-First (SJF) Preemptive 12 CSS430 Operating Systems : Scheduling 2 P2(2)P2(2) (SJF) Average waiting time = ( )/4 = 3 P3(4)P3(4) P 1 (0) P4(6)P4(6) P 3 ‘s waiting time = 0 P 2 ‘s waiting time = 2 P 3 ‘s waiting time = 4 P 4 ‘s waiting time = 6 P1P1 P2P2 P3P3 P4P4 6 (FCFS) Average waiting time = ( )/4 = Proces s Arrival Time CPU Burst Time P107 P226 P342 P453 4 ~P 2 ~P 1 18

V Compute average wait time (FCFS) for all unique permutations of P1, P2, P3 where: 2. What is the difference between preemptive and non-preemptive schedulers? 3.Can an OS satisfy all the scheduling criteria: CPU utilization, throughput, TAT, waiting time, and response time? Discussion 1 13 CSS430 Operating Systems : Scheduling ProcessCPU Burst Time (msec) P134 P216 P337

V0.1 Shortest-Job-First (SJF) 14 CSS430 Operating Systems : Scheduling  Optimal scheduling  Preemptive SJF is superior to non-preemptive SJF.  However, there are no accurate estimations to know the length of the next CPU burst  Estimation in Figure 5.3 (recursive smoothing filter): Exponential Averaging Filter (recursive smoothing filter)

V0.1 SJF Predicted CPU Burst Example (Random Data) 15 CSS430 Operating Systems : Scheduling

V0.1 Priority Scheduling 16 CSS430 Operating Systems : Scheduling  A priority number (integer) is associated with each process  The CPU is allocated to the process with the highest priority (smallest integer  highest priority in Unix but lowest in Java). Preemptive Preemptive Non-preemptive Non-preemptive  SJF is a special case of priority scheduling priority is the predicted next CPU burst time. priority is the predicted next CPU burst time.  Problem  Starvation – low priority processes may never execute.  Solution  Aging – as time progresses increase the priority of the process.

V CSS430 Operating Systems : Scheduling 1 P 5 (1) (Priority) Average waiting time = ( )/5 = 5.6 P 1 (6) P 3 (0) P 3 (9) Process CPU Burst Time Priority P173 P211 P334 P415 P552 P3P3 P1P1 P2P2 P5P5 6 (FCFS) Average waiting time = ( )/5 = Priority Scheduling Non-preemptive P4P P 4 (12)

V0.1 Round Robin Scheduling 18 CSS430 Operating Systems : Scheduling  Each process is given CPU time in turn, (i.e. time quantum: usually ms) ...thus waits no longer than ( n – 1 ) * time quantum  time quantum = 20ms P1P1 P2P2 P3P3 P4P4 P1P1 P3P3 P4P4 P1P1 P3P3 P3P P 1 (53) P 2 (17) P 3 (68) P 4 (24) P 1 (33) P 1 (13) P 3 (48) P 3 (28) P 3 (8) P 4 (4) 57 Process CPU Burst Time (ms) Wait Time (ms) TAT (ms) P = P P = P = AVERAGE41ms73ms114ms

V0.1 Round Robin Scheduling 19 CSS430 Operating Systems : Scheduling  Typically, higher average turnaround than SJF, but better response.  Performance (q = quantum) q large  FCFS q large  FCFS q small  q must be large with respect to context switch, otherwise overhead is too high. q small  q must be large with respect to context switch, otherwise overhead is too high.

V0.1 Turnaround Time (TAT) Varies With The Time Quantum 20 CSS430 Operating Systems : Scheduling TAT can be improved if most processes finish their next CPU burst in a single time quantum.

V0.1 Multilevel Queue Scheduling fixed distribution based on priority 21 CSS430 Operating Systems : Scheduling Each queue has its own scheduling algorithm, foreground (interactive) – RR, 80% CPU time background (batch) – FCFS, 20% CPU time

V0.1 Multilevel Feedback-Queue Scheduling (MFQS) – Variable based on consumption 22 CSS430 Operating Systems : Scheduling A new job enters queue Q 0 which is scheduled via FCFS. When it gains CPU, the current job receives 8 milliseconds. If it does not finish in 8 milliseconds, the job is moved to queue Q 1. At Q 1 job is again scheduled via FCFS and receives 16 additional milliseconds. If it still does not complete, it is preempted and moved to queue Q 2.

V0.1 Contention Scope 23 CSS430 Operating Systems : Scheduling TermDefinition PCSMany-to-many and many-to-one thread models schedule user-level threads to run on an available LWP SCSMapping kernel threads onto a CPU NOTE: Linux, Windows only use SCS because they are one-to-one thread models.

V0.1 Discussions 2 24 CSS430 Operating Systems : Scheduling ① What is the main problem in MFQS? ② How can you address this problem? Briefly think about your own personal scheduling algorithm?

V0.1 Cooperative multithreading in Java 25 CSS430 Operating Systems : Scheduling  A thread voluntary yielding control of the CPU is called cooperative multitasking.  Thread.yield( ) is OS-dependent. Linux does not care about it. Linux does not care about it. Solaris allows a thread to yield its execution when the corresponding LWP exhausts a given time quantum. Solaris allows a thread to yield its execution when the corresponding LWP exhausts a given time quantum.  Conclusion: Don’t write programs based on yield( ).

V0.1 Java-Based Round-Robin Scheduler (Naïve Example) 26 CSS430 Operating Systems : Scheduling

V0.1 Why does this not work? 27 CSS430 Operating Systems : Scheduling  Java: runs threads with a higher priority until they are blocked. (Threads with a lower priority cannot run concurrently.) This may cause starvation or deadlock. This may cause starvation or deadlock.  Java’s strict priority scheduling was implemented in Java green threads.  In Java 2, thread’s priority is typically mapped to the underlying OS-native thread’s priority.  OS: gives more CPU time to threads with a higher priority. (Threads with a lower priority can still run concurrently.)  If we do not want to depend on OS scheduling, we have to use: Thread.suspend( ) Thread.suspend( ) Thread.resume( ) Thread.resume( )

V0.1 Multiprocessor Scheduling 28 CSS430 Operating Systems : Scheduling  OS code and user process mapping: Asymmetric multiprocessing Asymmetric multiprocessing Symmetric multiprocessing (SMP) Symmetric multiprocessing (SMP)  Scheduling criteria: Processor affinity Processor affinity Load balancing Load balancing  Thread context switch: Coarse-grained software thread Coarse-grained software thread Fine-grained hardware thread Fine-grained hardware thread

V0.1 Algorithm Evaluation 29 CSS430 Operating Systems : Scheduling  Define the selection criteria (i.e.): Optimize CPU Utilization OR Optimize CPU Utilization OR Maximize throughput Maximize throughput  Evaluation Methods Deterministic Modeling (analytic method) Deterministic Modeling (analytic method) Queueing Models (see Little’s formula next) Queueing Models (see Little’s formula next) Simulations Simulations Implementation Implementation

V0.1 Little’s Formula 30 CSS430 Operating Systems : Scheduling n Average queue length Average arrival rate for new processes in queue W Average waiting time in queue

V0.1 Little’s Formula - Examples 31 CSS430 Operating Systems : Scheduling

V0.1Exercises 32 CSS430 Operating Systems : Scheduling ① Program #2: Check the syllabus for its due date ①(turn-in) Exercise Build a table or spreadsheet....for next Monday midnight deadline Note: this is in addition to the Tuesday assignment.