Operating Systems 1 K. Salah Module 2.2: CPU Scheduling Scheduling Types Scheduling Criteria Scheduling Algorithms Performance Evaluation.

Slides:



Advertisements
Similar presentations
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 17 Scheduling III.
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
Chapter 5 CPU Scheduling. CPU Scheduling Topics: Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling.
CPU Scheduling Algorithms
Chapter 3: CPU Scheduling
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 5: CPU Scheduling.
Operating Systems 1 K. Salah Module 2.1: CPU Scheduling Scheduling Types Scheduling Criteria Scheduling Algorithms Performance Evaluation.
University of Pennsylvania 10/5/00CSE 3801 CPU Scheduling CSE 380 Lecture Note 9 Insup Lee.
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.
6/25/2015Page 1 Process Scheduling B.Ramamurthy. 6/25/2015Page 2 Introduction An important aspect of multiprogramming is scheduling. The resources that.
What we will cover…  CPU Scheduling  Basic Concepts  Scheduling Criteria  Scheduling Algorithms  Evaluations 1-1 Lecture 4.
Chapter 5-CPU Scheduling
Job scheduling Queue discipline.
7/12/2015Page 1 Process Scheduling B.Ramamurthy. 7/12/2015Page 2 Introduction An important aspect of multiprogramming is scheduling. The resources that.
02/11/2004CSCI 315 Operating Systems Design1 CPU Scheduling Algorithms Notice: The slides for this lecture have been largely based on those accompanying.
1 Scheduling Algorithms FCFS First-Come, First-Served Round-robin SJF Multilevel Feedback Queues.
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.
Chapter 6 CPU SCHEDULING.
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.
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.
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  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.
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.
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 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.
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.
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.
CPU Scheduling G.Anuradha Reference : Galvin. CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time.
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.
Lecturer 5: Process Scheduling Process Scheduling  Criteria & Objectives Types of Scheduling  Long term  Medium term  Short term CPU Scheduling Algorithms.
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 Algorithms
Operating Systems Processes Scheduling.
CPU Scheduling.
Chapter 6: CPU Scheduling
CPU Scheduling G.Anuradha
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
3: CPU Scheduling Basic Concepts Scheduling Criteria
Chapter5: CPU Scheduling
Chapter 6: CPU Scheduling
Chapter 5: CPU Scheduling
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
Chapter 6: CPU Scheduling
CPU Scheduling.
CPU Scheduling: Basic Concepts
Module 5: CPU Scheduling
Presentation transcript:

Operating Systems 1 K. Salah Module 2.2: CPU Scheduling Scheduling Types Scheduling Criteria Scheduling Algorithms Performance Evaluation

Operating Systems 2 K. Salah CPU SCHEDULING –The basic problem is as follows: How can OS schedule the allocation of CPU cycles to processes in system, to achieve “good performance”? –Components of CPU scheduling subsystem of OS:  Dispatcher – gives control of the CPU to the new process  Scheduler - selects next process from those in main memory (short-term scheduler)  Swapper - manages transfer of processes between main memory and secondary storage (medium-term scheduler)  Long-Term Scheduler - in a batch system, determines which and how many jobs to admit into system.

Operating Systems 3 K. Salah Types of Scheduling Algorithms –Preemptive: process may have CPU taken away before completion of current CPU burst (e.g. end of CPU quantum.) –Non-preemptive: processes always run until CPU burst completes –Static Priority –Dynamic Priority

Operating Systems 4 K. Salah Performance Criteria for Scheduling Scheduling (as an Optimization task): How to best order the ready queue for efficiency purposes. CPU utilization: % of time CPU in use Throughput: # of jobs completed per time unit Turnaround Time: wall clock time required to complete a job Waiting Time: amount of time process is ready but waiting to run Response Time: in interactive systems, time until system responds to a command Response Ratio: (Turnaround Time)/(Execution Time) -- long jobs should wait longer The overhead of a scheduling algorithm (e.g., data kept about execution activity, queue management, context switches) should also be taken into account. Kleinrock's Conservation Law: No matter what scheduling algorithm is used, you cannot help one class of jobs without hurting the other ones. Example: A minor improvement for short jobs (say, on waiting time) causes a disproportionate degradation for long jobs.

Operating Systems 5 K. Salah Basic Scheduling Algorithm FCFS - First-Come, First-Served –Non-preemptive –Ready queue is a FIFO queue –Jobs arriving are placed at the end of queue –first job in queue runs to completion of CPU burst Advantages: simple, low overhead Disadvantages: long waiting time, inappropriate for interactive systems, large fluctuations in average turnaround time are possible.

Operating Systems 6 K. Salah FCFS Example Pid Arr CPU Start Finish Turna Wait Ratio A B C D E A B C D

Operating Systems 7 K. Salah RR - Round Robin Preemptive version FCFS Treat ready queue as circular –arriving jobs placed at end –first job in queue runs until completion of CPU burst, or until time quantum expires –if quantum expires, job again placed at end

Operating Systems 8 K. Salah Properties of RR Advantages: simple, low overhead, works for interactive systems Disadvantages: if quantum too small, too much time wasted in context switching; if too large, approaches FCFS. Typical value: msec Rule of thumb: choose quantum so that large majority (80- 90%) of jobs finish CPU burst in one quantum

Operating Systems 9 K. Salah SJF - Shortest Job First –non-preemptive –ready queue treated as a priority queue based on smallest CPU-time requirement  arriving jobs inserted at proper position in queue  shortest job (1st in queue) runs to completion Advantages: provably optimal w.r.t. average turnaround time Disadvantages: in general, unimplementable. Also, starvation possible! Can do it approximately: use exponential averaging to predict length of next CPU burst ==> pick shortest predicted burst next!

Operating Systems 10 K. Salah SJF - Shortest Job First SJF is Optimal: Let t 1, t 2, t 3,…, t n be the time taken for p 1, p 2, p 3, …,p n Also t 1 < t 2 <… < t n-1 < t n then the average turn around times for p i are: Tp 1 = t 1 ; Tp 2 = t 1 + t 2 ; Tp 3 = t 1 + t 2 + t 1 ; … Tp n = t 1 + t 2 + …+ t n-1 +t n ; average turnaround time = T A = (Tp 1 + Tp 2 +…+ Tp n ) / n = t 1 +(t 1 + t 2 )+(t 1 + t 2 + t 3 )+…+t n = nt 1 + (n-1) t 2 + (n-2) t 3 + …+ t n ) / n Now, if any of the t n is/are interchanged with t n-1 in the above equation T A ’ > T A, because (n-k) t j > (n-k) t k, where t j > t k Assumptions ? – Can p i (s) arrival times be different ?

Operating Systems 11 K. Salah Exponential Averaging  n+1  t n  n  n+1 : predicted length of next CPU burst t n : actual length of last CPU burst  n : previous prediction  : [0…1]  = 0 implies make no use of recent history  n+1  n   = 1 implies  n+1 = t n (past prediction not used).  = small value favor past history, larger value favors recent Why is keeping the history small good enough ? – Do the weight of the successive terms in the equation get smaller (why?)  n+1  t n  t n-1    t n-2  j  t n-j  j  0

Operating Systems 12 K. Salah SRTF - Shortest Remaining Time First –Preemptive version of SJF –Ready queue ordered on length of time till completion (shortest first) –Arriving jobs inserted at proper position –shortest job runs to completion (i.e. CPU burst finishes) or until a job with a shorter remaining time arrives (i.e. placed in the ready queue.)

Operating Systems 13 K. Salah Performance Evaluation Deterministic Modeling (vs. Probabilistic) Look at behavior of algorithm on a particular workload, and compute various performance criteria Example: workload - Job 1: 24 units Job 2: 3 units Job 3: 3 units Gantt chart for FCFS: | Job 1 | Job 2 | Job 3 | Total waiting time: = 51 Average waiting time: 51/3 = 17 Total turnaround time: = 81 Average turnaround time: 81/3 = 27

Operating Systems 14 K. Salah RR and SJF Chart for RR with quantum of 3: | Job 1 | Job 2 | Job 3 | Job 1 | Total waiting time: = 15 Avg. waiting time: 15 / 3 = 5 Chart for SJF: | Job 2 | Job 3 | Job 1 | Total waiting time: = 9 Avg. waiting time: 9 / 3 = 3 Can see that SJF gives minimum waiting time. RR is intermediate. (This can be proved in general.)

Operating Systems 15 K. Salah HPF - Highest Priority First –general class of algorithms –each job assigned a priority which may change dynamically –may be preemptive or non-preemptive Problem: how to compute priorities? –SJF is a special case of priority; the longer the CPU burst, the lower the priority. –Priority can be internally computed, e.g., CPU burst vs. I/O burst. Or it can be externally defined depending on the importance of the process, (e.g. using nice command in Unix).