1 Uniprocessor Scheduling Module 3.0. 2 CPU Scheduling n We concentrate on the problem of scheduling the usage of a single processor among all the existing.

Slides:



Advertisements
Similar presentations
Uniprocessor Scheduling Chapter 9 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College, Venice,
Advertisements

Chapter 9 Uniprocessor Scheduling Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College, Venice,
Chapter 9 Uniprocessor Scheduling
1 Uniprocessor Scheduling Types of scheduling –The aim of processor scheduling is to assign processes to be executed by the processor so as to optimize.
Chapter 9 Uniprocessor Scheduling
A. Frank - P. Weisberg Operating Systems Advanced CPU Scheduling.
Chapter 9 Uniprocessor Scheduling Operating Systems: Internals and Design Principles, 6/E William Stallings Dave Bremer Otago Polytechnic, N.Z. ©2008,
Chapter 9 Uniprocessor Scheduling Operating Systems: Internals and Design Principles, 6/E William Stallings Dave Bremer Otago Polytechnic, N.Z. ©2008,
Day 25 Uniprocessor scheduling. Algorithm: Selection function Selection function – which process among ready processes to select. w – time spent in system,
Chapter 9 Uniprocessor Scheduling
Uniprocessor Scheduling Chapter 9. Aim of Scheduling The key to multiprogramming is scheduling Scheduling is done to meet the goals of –Response time.
6/25/2015Page 1 Process Scheduling B.Ramamurthy. 6/25/2015Page 2 Introduction An important aspect of multiprogramming is scheduling. The resources that.
Chapter 9 Uniprocessor Scheduling
1 Uniprocessor Scheduling Chapter 9. 2 Aims of Scheduling Assign processes to be executed by the processor(s) Response time Throughput Processor efficiency.
A. Frank - P. Weisberg Operating Systems CPU Scheduling.
7/12/2015Page 1 Process Scheduling B.Ramamurthy. 7/12/2015Page 2 Introduction An important aspect of multiprogramming is scheduling. The resources that.
1 Lecture 10: Uniprocessor Scheduling. 2 CPU Scheduling n The problem: scheduling the usage of a single processor among all the existing processes in.
1Chapter 05, Fall 2008 CPU Scheduling The CPU scheduler (sometimes called the dispatcher or short-term scheduler): Selects a process from the ready queue.
Chapter 9 Uniprocessor Scheduling Seventh Edition By William Stallings Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals.
1 CPU Scheduling & Deadlock Operating Systems Lecture 4.
1 Uniprocessor Scheduling Chapter 9. 2 Aim of Scheduling Main Job: Assign processes to be executed by the processor(s) and processes to be loaded in main.
Chapter 9 Uniprocessor Scheduling Seventh Edition By William Stallings Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals.
Uniprocessor Scheduling
CPU Scheduling Chapter 6 Chapter 6.
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.
10CSE CPU Scheduling Copyrights Lecture Slides adapted from “ Advanced Operating Systems ”, Lecture Notes by Prof. Prof. Daniel Mosse, University Of Pittsburgh,
Lecture 5: Uniprocessor Scheduling
1 Uniprocessor Scheduling Chapter 9. 2 CPU Scheduling We concentrate on the problem of scheduling the usage of a single processor among all the existing.
Chapter 9 Uniprocessor Scheduling Spring, 2011 School of Computer Science & Engineering Chung-Ang University.
Chapter 9 Uniprocessor Scheduling Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College, Venice,
Chapter 9 Uniprocessor Scheduling Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College, Venice,
Chapter 6 CPU SCHEDULING.
Chapter 9 Uniprocessor Scheduling Seventh Edition By William Stallings Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals.
Operating System Chapter 9. Uniprocessor Scheduling
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)
Uniprocessor Scheduling Chapter 9. Aim of Scheduling Minimize response time Maximize throughput Maximize processor efficiency.
1 Our focus  scheduling a single CPU among all the processes in the system  Key Criteria: Maximize CPU utilization Maximize throughput Minimize waiting.
1 Uniprocessor Scheduling Chapter 9. 2 CPU Scheduling n We concentrate on the problem of scheduling the usage of a single processor among all the existing.
Lecture 7: Scheduling preemptive/non-preemptive scheduler CPU bursts
1 Uniprocessor Scheduling Chapter 9. 2 Aim of Scheduling Response time Throughput Processor efficiency.
Uniprocessor Scheduling Chapter 9. Aim of Scheduling Response time Throughput Processor efficiency.
Uniprocessor Scheduling
Operating System 9 UNIPROCESSOR SCHEDULING. TYPES OF PROCESSOR SCHEDULING.
Uniprocessor Scheduling Chapter 9. Processor Scheduling Processor scheduling determines the assignment of processes to be executed by the processor over.
Uniprocessor Scheduling Chapter 9. Aim of Scheduling Assign processes to be executed by the processor or processors: –Response time –Throughput –Processor.
1 Uniprocessor Scheduling Chapter 3. 2 Alternating Sequence of CPU And I/O Bursts.
Chapter 9 Uniprocessor Scheduling Operating Systems: Internals and Design Principles, 6/E William Stallings Dave Bremer Otago Polytechnic, N.Z. ©2008,
1 Uniprocessor Scheduling Chapter 9. 2 Aim of Scheduling Assign processes to be executed by the processor(s) Response time Throughput Processor efficiency.
Uniprocessor Scheduling Chapter 9 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College, Venice,
Uniprocessor Scheduling
CPU Scheduling Chapter 5.
Uniprocessor Scheduling
Process Scheduling B.Ramamurthy 11/18/2018.
Uniprocessor Scheduling
Uniprocessor scheduling
Operating System Chapter 9. Uniprocessor Scheduling
Process Scheduling B.Ramamurthy 12/5/2018.
Chapter 9 Uniprocessor Scheduling
Chapter 9 Uniprocessor Scheduling
Process Scheduling B.Ramamurthy 2/23/2019.
Process Scheduling B.Ramamurthy 2/23/2019.
Process Scheduling B.Ramamurthy 2/23/2019.
Process Scheduling B.Ramamurthy 2/23/2019.
Process Scheduling B.Ramamurthy 4/11/2019.
Process Scheduling B.Ramamurthy 4/7/2019.
Process Scheduling B.Ramamurthy 4/19/2019.
Process Scheduling B.Ramamurthy 4/24/2019.
Process Scheduling B.Ramamurthy 5/7/2019.
Uniprocessor Scheduling
Presentation transcript:

1 Uniprocessor Scheduling Module 3.0

2 CPU Scheduling n We concentrate on the problem of scheduling the usage of a single processor among all the existing processes in the system n The goal is to achieve u High processor utilization u High throughput F number of processes completed per unit time u Low response time F time elapsed from the submission of a request to the beginning of the response

3 Classification of Scheduling Activity n Long-term: which process to admit n Medium-term: which process to swap in or out n Short-term: which ready process to execute next

4

5 Queuing Diagram for Scheduling

6 Long-Term Scheduling n Determines which programs are admitted to the system for processing n Controls the degree of multiprogramming n If more processes are admitted u less likely that all processes will be blocked F better CPU usage u each process has less fraction of the CPU n The long term scheduler may attempt to keep a mix of processor-bound and I/O- bound processes

7 Medium-Term Scheduling n Swapping decisions based on the need to manage multiprogramming n Done by memory management software n Linux Daemon u kswapd

8 Short-Term Scheduling n Determines which process is going to execute next (also called CPU scheduling) n Is the subject of this module. Our Focus. n The short term scheduler is known as the dispatcher n Is invoked on a event that may lead to choose another process for execution: u clock interrupts u I/O interrupts u operating system calls and traps u signals

9 Short-Term Scheduling Criteria n User-oriented u Response Time: For interactive systems. Elapsed time from the submission of a request to the beginning of response u Turnaround Time: Elapsed time from the submission of a process to its completion n System-oriented u processor utilization u fairness u throughput: number of process completed per unit time

10 Short-Tem Scheduling Criteria n Performance-related u Quantitative u Measurable such as response time and throughput n Not performance related u Qualitative u E.g., Predictability F A given job should take the same amount of time as similar pervious one regardless of system load. Big variance of run time is disturbing to users.

11 Priorities n Implemented by having multiple ready queues to represent each level of priority n Scheduler will always choose a process of higher priority over one of lower priority n Lower-priority may suffer starvation n Then allow a process to change its priority based on its age or execution history n Our first scheduling algorithms will not make use of priorities n We will then present other algorithms that use dynamic priority mechanisms

12

13 Characterization of Scheduling Policies n The selection function: determines which process in the ready queue is selected next for execution n The decision mode: specifies the instants in time at which the selection function is exercised u Nonpreemptive F Once a process is in the running state, it will continue until it terminates or blocks itself for I/O u Preemptive F Currently running process may be interrupted and moved to the Ready state by the OS F Allows for better service since any one process cannot monopolize the processor for very long

14 The CPU-I/O Cycle n We observe that processes require alternate use of processor and I/O in a repetitive fashion n Each cycle consist of a CPU burst (typically of 5 ms) followed by a (usually longer) I/O burst n A process terminates on a CPU burst n CPU-bound processes have longer CPU bursts than I/O-bound processes

15 Our running example to discuss various scheduling policies Process Arrival Time Service Time Service time = total processor time needed in one (CPU-I/O) cycle Jobs with long service time are CPU-bound jobs and are referred to as “long jobs”

16 First Come First Served (FCFS) First Come First Served (FCFS) n Selection function: the process that has been waiting the longest in the ready queue (hence, FCFS) n Decision mode: nonpreemptive u process runs until it blocks itself

17 FCFS drawbacks n A process that does not perform any I/O will monopolize the processor n Favors CPU-bound processes u I/O-bound processes have to wait until CPU-bound process completes u They may have to wait even when their I/O are completed (poor I/O device utilization) u we could have kept the I/O devices busy by giving a bit more priority to I/O bound processes F Low I/O utilization n Not an attractive alternative. Usually used with priority scheduling.

18 n Selection function: same as FCFS n Decision mode: preemptive u a process is allowed to run until the time slice period (quantum, typically from 10 to 100 ms) has expired u then a clock interrupt occurs and the running process is put on the ready queue Round-Robin Round-Robin

19 Time Quantum for Round Robin The principal design issue is the length of q. –If q is too short, short processes will move through the system quickly. However, there is a scheduling and switching overhead. –If q is too large, it acts like FCFS. –Rule of thumb, q should be slightly greater than CPU burst. n must be substantially larger than the time required to handle the clock interrupt and dispatching n should be larger than the typical interaction (but not much more to avoid penalizing I/O bound processes)

20 Effect of q size

21 Round Robin: critique n Still favors CPU-bound processes u A I/O bound process uses the CPU for a time less than the time quantum and then is blocked waiting for I/O u A CPU-bound process run for all its time slice and is put back into the ready queue (thus getting in front of blocked processes) n A solution: virtual round robin u When a I/O has completed, the blocked process is moved to an auxiliary queue which gets preference over the main ready queue u A process dispatched from the auxiliary queue runs no longer than the basic time quantum minus the time spent running since it was selected from the ready queue

22 Queuing for Virtual Round Robin

23 Shortest Process Next (SPN) Shortest Process Next (SPN) n Selection function: the process with the shortest expected CPU burst time n Decision mode: nonpreemptive n I/O bound processes will be picked first n We need to estimate the required processing time (CPU burst time) for each process

24 Estimating the required CPU burst n Let T[i] be the execution time for the ith instance of this process: the actual duration of the ith CPU burst of this process n Let S[i] be the predicted value for the ith CPU burst of this process. The simplest choice is:  S[n+1] = (1/n)  _{i=1 to n} T[i] n To avoid recalculating the entire sum we can rewrite this as: u S[n+1] = (1/n) T[n] + ((n-1)/n) S[n] n But this convex combination gives equal weight to each instance

25 Estimating the required CPU burst n But recent instances are more likely to reflect future behavior n A common technique for that is to use exponential averaging  S[n+1] =  T[n] + (1-  ) S[n] ; 0 <  < 1  more weight is put on recent instances whenever  > 1/2 n By expanding this eqn, we see that weights of past instances are decreasing exponentially  S[n+1] =  T[n] + (1-  )  T[n-1] +... (1-  )^{i}  T[n-i] + ... + (1-  )^{n}S[1]  predicted value of 1st instance S[1] is not calculated; usually set to 0 to give priority to to new processes

26 Exponentially Decreasing Coefficients

27 Shortest Process Next: critique n Possibility of starvation for longer processes as long as there is a steady supply of shorter processes n Lack of preemption is not suited in a time sharing environment u CPU bound process gets lower priority (as it should) but a process doing no I/O could still monopolize the CPU if he is the first one to enter the system n SPN implicitly incorporates priorities: shortest jobs are given preferences n The next (preemptive) algorithm penalizes directly longer jobs

28 Shortest Remaining Time Shortest Remaining Time n Preemptive version of shortest process next policy n The scheduler always chooses process with the shortest expected remaining time that the currently running process. n Must estimate processing time n Gives superior turnaround time than SPN: a short job is given immediate attention. n Unlike RR, no timer interrupt is needed for preemption

29 Highest Response Ratio Next (HRRN) n Choose next process with the greatest value of: n The idea is to count for the age of the process. Favor shorter jobs initially (smaller denominator), but longer jobs start competing with shorter jobs as “waiting time” increases. n Need to estimate expected service time time spent waiting + expected service time expected service time

30 Feedback n If we have no indication of the relative length of various processes, then non of SPN, SRT, HRRN can be used. n Establish preference by penalizing jobs that have been running longer u I.e. if we cannot focus on the time remaining to execute, let us focus on time spent in execution so far.

31 Multilevel Feedback Scheduling n Preemptive scheduling with dynamic priorities n Several ready to execute queues with decreasing priorities: u P(RQ0) > P(RQ1) >... > P(RQn) n New process are placed in RQ0 n When they reach the time quantum, they are placed in RQ1. If they reach it again, they are place in RQ2... until they reach RQn n I/O-bound processes will stay in higher priority queues. CPU-bound jobs will drift downward. n Dispatcher chooses a process for execution in RQi only if RQi-1 to RQ0 are empty n Hence long jobs may starve

32 Multiple Feedback Queues n FCFS is used in each queue except for lowest priority queue where Round Robin is used

33 Time Quantum for feedback Scheduling Time Quantum for feedback Scheduling n With a fixed quantum time, the turnaround time of longer processes can stretch out alarmingly n To compensate we can increase the time quantum according to the depth of the queue u Ex: time quantum of RQi = 2^{i-1} n Longer processes may still suffer starvation. Possible fix: promote a process to higher priority after some time

34 Algorithm Comparison n Which one is best? n The answer depends on: u on the system workload (extremely variable) u hardware support for the dispatcher u relative weighting of performance criteria (response time, CPU utilization, throughput...) u The evaluation method used (each has its limitations...) n Hence the answer depends on too many factors to give any...

35 Fair Share Scheduling n In a multiuser system, each user can own several processes n Users belong to groups and each group should have its fair share of the CPU n This is the philosophy of fair share scheduling n Ex: if there are 4 equally important departments (groups) and one department has more processes than the others, degradation of response time should be more pronounced for that department

36 The Fair Share Scheduler (FSS) n Has been implemented on some Unix OS n Processes are divided into groups n Group k has a fraction Wk of the CPU n The priority Pj[i] of process j (belonging to group k) at time interval i is given by: u CPU j := U j-1 /2 +CPU j-1 /2 u GCPU k := GU k-1 /2 + GCPU k-1 /2 u P j := Base j + CPU j /2 + GCPU k /(4*W k ) F A high value means a low priority F Process with highest priority is executed next F Bj = base priority of process j F CPUj[i] = Measure of processor usage by process j in time interval i F GCPUk[i] = Measure of processor usage by group k in time interval I F Wk= weighting assigned to group k, with 0<Wk<1 and Sum of all Wk =1 ½ and ¼ are chosen to reduce computation. Simple done by shifting operations.

37 The Fair Share Scheduler (FSS) n Recall that u Pj[i] = Bj + (1/2) CPUj[i-1] + GCPUk[i- 1]/(4Wk) n The priority decreases as the process and group use the processor n With more weight Wk, group usage decreases less the priority

38 In this example, wk is chosen to be ½.

39 Traditional UNIX Scheduling n Multilevel feedback using round robin within each of the priority queues n Priorities are recomputed once per second n Base priority divides all processes into fixed bands of priority levels n Adjustment factor used to keep process in its assigned band n Same for both SVR3 and 4.3 BSD (SVR4 is different) u Similar to Fair-share scheduling u Values F P j Priority of process j F U j Processor use by j u Calculations (done each second): F CPU j := U j-1 /2 +CPU j-1 /2 F P j := Base j + CPU j /2 + nice j

40 Bands n Decreasing order of priority u Swapper u Block I/O device control u File manipulation u Character I/O device control u User processes