CHAPTER 2 PROCESSOR SCHEDULING PART V by U ğ ur HALICI.

Slides:



Advertisements
Similar presentations
CHAPTER 2 PROCESSOR SCHEDULING PART I By U ğ ur HALICI.
Advertisements

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.
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.
1Chapter 05, Fall 2008 CPU Scheduling The CPU scheduler (sometimes called the dispatcher or short-term scheduler): Selects a process from the ready queue.
Uniprocessor Scheduling
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.
CPU-Scheduling Whenever the CPU becomes idle, the operating system must select one of the processes in the ready queue to be executed. The short term scheduler.
Operating Systems Part III: Process Management (CPU Scheduling)
Chapter 6: CPU Scheduling
CS3530 OPERATING SYSTEMS Summer 2014 Processor Scheduling Chapter 5.
CS212: OPERATING SYSTEM Lecture 3: Process Scheduling 1.
Chapter 6 CPU SCHEDULING.
Round Robin Scheduling A preemptive scheduling designed for Time Sharing Systems The Ready Queue is treated as a circular queue A small execution.
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.
Uniprocessor Scheduling Chapter 9. Aim of Scheduling To improve: Response time: time it takes a system to react to a given input Turnaround Time (TAT)
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.
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.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 5: Process Scheduling.
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.
Process Program (Passive Entity) is a sequence of instructions, written to perform a specified task on a computer. A computer requires programs to function,
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.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 5: CPU Scheduling.
Introduction to Operating System Created by : Zahid Javed CPU Scheduling Fifth Lecture.
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.
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.
Lecturer 5: Process Scheduling Process Scheduling  Criteria & Objectives Types of Scheduling  Long term  Medium term  Short term CPU Scheduling Algorithms.
 In a single-processor system, only one process can run at a time; any others must wait until the CPU is free and can be rescheduled.  The objective.
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.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
CPU Scheduling Optimization of CPU scheduling implies
CPU SCHEDULING.
April 6, 2001 Gary Kimura Lecture #6 April 6, 2001
Uniprocessor Scheduling
Chapter 6: CPU Scheduling
CPU Scheduling Basic Concepts Scheduling Criteria
Chapter 6: CPU Scheduling
Chapter 5: CPU Scheduling
Operating System Concepts
Processor Scheduling Hank Levy 1.
Chapter 6: Scheduling Algorithms Dr. Amjad Ali
Presentation transcript:

CHAPTER 2 PROCESSOR SCHEDULING PART V by U ğ ur HALICI

2.3.4 Round-Robin Scheduling (RRS)  In RRS algorithm the ready queue is treated as a FIFO circular queue.  The RRS traces the ready queue allocating the processor to each process for a time interval which is smaller than or equal to a predefined time called time quantum (slice). 1

2.3.4 Round-Robin Scheduling (RRS)  The OS using RRS, takes the first process from the ready queue, gives the processor to that process and sets a timer to interrupt when time quantum expires.  If the process has a processor burst time smaller than the time quantum, then it releases the processor voluntarily, either by terminating or by issuing an I/O request.  The OS then proceed with the next process in the ready queue. 2

2.3.4 Round-Robin Scheduling (RRS)  The performance of RRS depends heavily on the selected time quantum.  Time quantum    RRS becomes FCFS  Time quantum  0  RRS becomes processor sharing (It acts as if each of the n processes has its own processor running at processor speed divided by n)  However, if time quantum is too small then context switch time can not be ignored anymore.  For an optimum time quantum, it can be selected to be greater than 80 % of processor bursts and to be greater than the context switching time. 3

2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : 44 4 B28 : C32 : D71 : 11 1 RQ : A:4:4Proc in CPU:Q:3 : 0 FCFS RR next_cpu_burst : remaining_time Time quantum used 4

2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : 244 : 44 B28 : C32 : D71 : 11 1 RQ : B:8:8Proc in CPU:A:4:2Q:3 : 2 FCFS RR next_cpu_burst : remaining_time 5

2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : 144 : 44 B28 : C32 : D71 : 11 1 RQ : B:8:8C:2:2A:4:1Proc in CPU:A:4:1Q:3 : 3 expires preemption p 6

2.2 Process States If more than one processes are to enter the Ready Queue at the same time then give priority as: 1: process just submitted 2: process completed I/O 3: process preempted CPU I/O requested I/O completed START WAITING READY RUNNING HALTED preeemption 132 7

2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : 144 : 44 B28 : 518 : 8-- C32 : D71 : 11 1 RQ : C:2:2A:4:1B:8:5Proc in CPU:B:8:5Q:3 : 3 expires preemption pp 8

2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : 144 : 44 B28 : 518 : 8-- C32 : 112 : 2-- D71 : 11 1 RQ : A:4:1B:8:5D:1:1Proc in CPU:C:2:1Q:3 : 1 expires pp 9

2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : 144 : 44 B28 : 518 : 8-- C32 : 012 : 2-- D71 : 11 1 RQ : A:4:1B:8:5D:1:1Proc in CPU:Q:3 : 0 expires pp 10

2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : 044 : 44 B28 : 518 : 8-- C32 : 012 : 2-- D71 : 11 1 RQ : B:8:5D:1:1C:2:2Proc in CPU:Q:3 : 0 expires pp 11

2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : 044 : 44 B28 : 218 : 8-- C32 : 012 : 2-- D71 : 11 1 RQ : D:1:1C:2:2B:8:2Proc in CPU:B:8:2Q:3 : 3 expires pp preemption p 12

2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : 044 : 44 B28 : 218 : 8-- C32 : 012 : 2-- D71 : 011 : 11 RQ : C:2:2B:8:2A:4:4Proc in CPU:Q:3 : 0 expires ppp 13

2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : 044 : 44 B28 : 218 : 8-- C32 : 012 : 1-- D71 : 011 : 11 RQ : B:8:2A:4:4D:1:1Proc in CPU:C:2:1Q:3 : 1 expires ppp 14

2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : 044 : 44 B28 : 218 : 8-- C32 : D71 : 011 : 11 RQ : B:8:2A:4:4D:1:1Proc in CPU:Q:3 : 0 expires ppp 15

2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : 044 : 44 B28 : 018 : 8-- C32 : D71 : 011 : 11 RQ : A:4:4D:1:1Proc in CPU:Q:3 : 0 expires ppp 16

2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : 044 : 344 : 4 B28 : 018 : 8-- C32 : D71 : 011 : 11 RQ : D:1:1B:8:8Proc in CPU:A:4:3Q:3 : 1 expires ppp 17

2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : 044 : 144 : 4 B28 : 018 : 8-- C32 : D71 : 011 : 11 RQ : D:1:1B:8:8A:4:1Proc in CPU:A:4:1Q:3 : 3 expires ppp preemption p 18

2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : 044 : 144 : 4 B28 : 018 : 8-- C32 : D71 : : 1 RQ : B:8:8A:4:1Proc in CPU:Q:3 : 0 expires pppp 19

2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : 044 : 144 : 4 B28 : 018 : 7-- C32 : D71 : : 1 RQ : A:4:1D:1:1Proc in CPU:B:8:7Q:3 : 1 expires pppp 20

2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : 044 : 144 : 4 B28 : 018 : 5-- C32 : D71 : : 1 RQ : A:4:1D:1:1B:8:5Proc in CPU:B:8:5Q:3 : 3 expires ppppp preemption 21

2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : : 4 B28 : 018 : 5-- C32 : D71 : : 1 RQ : D:1:1B:8:5Proc in CPU:Q:3 : 0 expires ppppp 22

2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : : 4 B28 : 018 : 5-- C32 : D71 : 01 1 RQ : B:8:5Proc in CPU:Q:3 : 0 expires ppppp 23

2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : : 4 B28 : 018 : 2-- C32 : D71 : 01 1 RQ : A:4:4B:8:2Proc in CPU:B:8:2Q:3 : 0 expires ppppp preemption p 24

2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : : 1 B28 : 018 : 2-- C32 : D71 : 01 1 RQ : B:8:2A:4:1Proc in CPU:A:4:1Q:3 : 3 expires ppppp preemption pp 25

2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : : 1 B28 : C32 : D71 : 01 1 RQ : A:4:1Proc in CPU:Q:3 : 0 expires ppppppp 26

2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : 04 4 B28 : C32 : D71 : 01 1 RQ : Proc in CPU:Q:3 : 0 expires ppppppp 27

2.3.4 Round-Robin Scheduling (RRS)  Processor utilization = (35 / 35) * 100 = 100 %  Throughput = 4 / 35 ppppppp 28

2.3.4 Round-Robin Scheduling (RRS)  Turn around time: tat A = 35 – 0 = 35 tat B = 34 – 2 = 32 tat C = 15 – 3 =12 tat D = 26 – 7 = 19 tat AVG = ( ) / 4 = 24. p pppppp 29

2.3.4 Round-Robin Scheduling (RRS)  Turn around time: tat A = 35 – 0 = 35 tat B = 34 – 2 = 32 tat C = 15 – 3 =12 tat D = 26 – 7 = 19 tat AVG = ( ) / 4 = 24. p pppppp 30

2.3.4 Round-Robin Scheduling (RRS)  Turn around time: tat A = 35 – 0 = 35 tat B = 34 – 2 = 32 tat C = 15 – 3 =12 tat D = 26 – 7 = 19 tat AVG = ( ) / 4 = 24. p pppppp 31

2.3.4 Round-Robin Scheduling (RRS)  Turn around time: tat A = 35 – 0 = 35 tat B = 34 – 2 = 32 tat C = 15 – 3 =12 tat D = 26 – 7 = 19 tat AVG = ( ) / 4 = 24. p pppppp 32

2.3.4 Round-Robin Scheduling (RRS)  Turn around time: tat A = 35 – 0 = 35 tat B = 34 – 2 = 32 tat C = 15 – 3 =12 tat D = 26 – 7 = 19 tat AVG = ( ) / 4 = 24 p pppppp 33

2.3.4 Round-Robin Scheduling (RRS)  Waiting time: wt A = (0 – 0)+(8 – 3)+(17 – 13)+(24 – 20)+(29 – 29)+(34 – 32)=15 wt B = (3 – 2)+(9 – 6)+ (15 -12)+(21 – 18)+(26 – 24)+(32 – 29) =15 wt C = (6 – 3) + (13 – 9) = 7 wt D = (12 – 7) + (20 – 14) + (25 – 22) = 14 wt AVG = ( ) / 4 = p pppppp 34

2.3.4 Round-Robin Scheduling (RRS)  Waiting time: wt A = (0 – 0)+(8 – 3)+(17 – 13)+(24 – 20)+(29 – 29)+(34 – 32)=15 wt B = (3 – 2)+(9 – 6)+ (15 -12)+(21 – 18)+(26 – 24)+(32 – 29) =15 wt C = (6 – 3) + (13 – 9) = 7 wt D = (12 – 7) + (20 – 14) + (25 – 22) = 14 wt AVG = ( ) / 4 = p pppppp 35

2.3.4 Round-Robin Scheduling (RRS)  Waiting time: wt A = (0 – 0)+(8 – 3)+(17 – 13)+(24 – 20)+(29 – 29)+(34 – 32)=15 wt B = (3 – 2)+(9 – 6)+ (15 -12)+(21 – 18)+(26 – 24)+(32 – 29) =15 wt C = (6 – 3) + (13 – 9) = 7 wt D = (12 – 7) + (20 – 14) + (25 – 22) = 14 wt AVG = ( ) / 4 = p pppppp 36

2.3.4 Round-Robin Scheduling (RRS)  Waiting time: wt A = (0 – 0)+(8 – 3)+(17 – 13)+(24 – 20)+(29 – 29)+(34 – 32)=15 wt B = (3 – 2)+(9 – 6)+ (15 -12)+(21 – 18)+(26 – 24)+(32 – 29) =15 wt C = (6 – 3) + (13 – 9) = 7 wt D = (12 – 7) + (20 – 14) + (25 – 22) = 14 wt AVG = ( ) / 4 = p pppppp 37

2.3.4 Round-Robin Scheduling (RRS)  Waiting time: wt A = (0 – 0)+(8 – 3)+(17 – 13)+(24 – 20)+(29 – 29)+(34 – 32)=15 wt B = (3 – 2)+(9 – 6)+ (15 -12)+(21 – 18)+(26 – 24)+(32 – 29) =15 wt C = (6 – 3) + (13 – 9) = 7 wt D = (12 – 7) + (20 – 14) + (25 – 22) = 14 wt AVG = ( ) / 4 = p pppppp 38

2.3.4 Round-Robin Scheduling (RRS)  Response time: rt A = 0 – 0 = 0 rt B = 36 – 2 = 1 rt C = 6 – 3 = 3 rt D = 12 – 7 = 5 rt AVG = ( ) / 4 = 2.25 p pppppp 39

2.3.4 Round-Robin Scheduling (RRS)  Response time: rt A = 0 – 0 = 0 rt B = 3 – 2 = 1 rt C = 6 – 3 = 3 rt D = 12 – 7 = 5 rt AVG = ( ) / 4 = 2.25 p pppppp 40

2.3.4 Round-Robin Scheduling (RRS)  Response time: rt A = 0 – 0 = 0 rt B = 36 – 2 = 1 rt C = 6 – 3 = 3 rt D = 12 – 7 = 5 rt AVG = ( ) / 4 = 2.25 p pppppp 41

2.3.4 Round-Robin Scheduling (RRS)  Response time: rt A = 0 – 0 = 0 rt B = 36 – 2 = 1 rt C = 6 – 3 = 3 rt D = 12 – 7 = 5 rt AVG = ( ) / 4 = 2.25 p pppppp 42

2.3.4 Round-Robin Scheduling (RRS)  Response time: rt A = 0 – 0 = 0 rt B = 3 – 2 = 1 rt C = 6 – 3 = 3 rt D = 12 – 7 = 5 rt AVG = ( ) / 4 = 2.25 p pppppp 43

2.3.4 Round-Robin Scheduling (RRS)  In Round Robin Scheduling it is guaranteed that rt max ≤ (n-1)*Q where n : multiprogramming degree Q: time quantum 44

comparison FCFSSPFSRTFRR tat avg wt avg rt avg Easy to implement Not possible to know next CPU burst exactly, it can only be guessed Implementable, rt max is important for interactive systems 45

2.3.5 Priority Scheduling  In this type of algorithms a priority is associated with each process and the processor is given to the process with the highest priority. Equal priority processes are scheduled with FCFS method.  To illustrate, SPF is a special case of priority scheduling algorithm where Priority(i) = 1 / next processor burst time of process i or Priority(i) = K - next processor burst time of process i 46

2.3.5 Priority Scheduling  Priorities can be fixed externally or they may be calculated by the OS from time to time.  Externally, if all users have to code time limits and maximum memory for their programs, priorities are known before execution.  Internally, a next processor burst time prediction such as that of SPF can be used to determine priorities dynamically. 47

2.3.5 Priority Scheduling  A priority scheduling algorithm can leave some low-priority processes in the ready queue indefinitely.  If the system is heavily loaded, it is a great probability that there is a higher-priority process to grab the processor.  This is called the starvation problem.  One solution for the starvation problem might be to gradually increase the priority of processes that stay in the system for a long time. 48

2.3.5 Priority Scheduling Example: Following may be used as a priority defining function: Priority (i) = 10 + t now – t s (i) – t rq (i) – t cpu (i) Where t s (i): the time process n is submitted to the system T rq (i): the time process n entered to the ready queue last time T cpu (i): next processor burst length of process n t now : current time  P(i)=t now – t rq (i)≈FCFS  P(i)=K – t cpu (i)≈SPF  P(i)= α (t now – t rq (i))+(1- α )(K – t cpu (i)), ≈combination of FCFS & SPF 49