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.

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.
1 Uniprocessor Scheduling Module CPU Scheduling n We concentrate on the problem of scheduling the usage of a single processor among all the existing.
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.
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
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.
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.
Uniprocessor scheduling
Process Scheduling B.Ramamurthy 4/19/2019.
Process Scheduling B.Ramamurthy 4/24/2019.
Process Scheduling B.Ramamurthy 5/7/2019.
Uniprocessor Scheduling
Uniprocessor Scheduling
Presentation transcript:

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 processes in the system Assign processes to be executed by the processor

3 Goals of Scheduling  High processor utilization  High throughput  number of processes completed per unit time  Low response time  time elapse from the submission of a request to the beginning of the response

4 Types of Scheduling

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

6 Medium-Term Scheduling Swapping decisions based on the need to manage multiprogramming Closely related to memory management software and discussed intensively in chapter 8  see resident set allocation and load control

7 Short-Term Scheduling Determines which process is going to execute next (also called CPU scheduling) Is the subject of this chapter The short term scheduler is known as the dispatcher Executes most frequently Is invoked on a event that may lead to choose another process for execution:  clock interrupts, time quantum expires  I/O interrupts  operating system calls and traps  signals

8 Scheduling and Process State Transitions Long-term: which process to admit Medium-term: which process to swap in or out Short-term: which ready process to execute next

9 Scheduling and Process State Transitions Long-term: which process to admit Medium-term: which process to swap in or out Short-term: which ready process to execute next

10 Scheduling and Process State Transitions Long-term: which process to admit Medium-term: which process to swap in or out Short-term: which ready process to execute next

11 Scheduling and Process State Transitions Long-term: which process to admit Medium-term: which process to swap in or out Short-term: which ready process to execute next

12 Levels of Scheduling

13 Short-Term Scheduling Criteria User Oriented Criteria  Takes into account individual users System Oriented Criteria  Takes into account the system as a whole

14 Short-Term Scheduling Criteria Performance-related  Quantitative  Measurable such as response time and throughput

15 Short-Term Scheduling Criteria Performance-related  Quantitative  Measurable such as response time and throughput Other  Qualitative  Difficult to measure

16 Scheduling Criteria

17 Scheduling Criteria

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

19 Priority Queuing Diagram

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

21 Our running example to discuss various scheduling policies Process Arrival Time Service Time Service time = total processor time needed Jobs with long service time are CPU-bound jobs and are referred to as “long jobs”

22 First Come First Served (FCFS) Selection function: the process that has been waiting the longest in the ready queue (hence, FCFS) Decision mode: nonpreemptive  a process run until it blocks itself

23 First Come First Served (FCFS) Selection function: the process that has been waiting the longest in the ready queue (hence, FCFS) Decision mode: nonpreemptive  a process run until it blocks itself

24 First Come First Served (FCFS) Selection function: the process that has been waiting the longest in the ready queue (hence, FCFS) Decision mode: nonpreemptive  a process run until it blocks itself

25 FCFS drawbacks A process that does not perform any I/O will monopolize the processor  Starvation may occur or long response time for some processes  Throughput may be low, even though utilization could be high Favors CPU-bound processes  I/O-bound processes have to wait until CPU-bound process completes  They may have to wait even when their I/O are completed (poor device utilization)  we could have kept the I/O devices busy by giving a bit more priority to I/O bound processes

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

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

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

29 Time Quantum for Round Robin must be substantially larger than the time required to handle the clock interrupt and dispatching should be larger then the typical interaction (but not much more to avoid penalizing I/O bound processes)

30 Round Robin: critique Still favors CPU-bound processes  A I/O bound process uses the CPU for a time less than the time quantum and then is blocked waiting for I/O  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) A solution: virtual round robin  When a I/O has completed, the blocked process is moved to an auxiliary queue which gets preference over the main ready queue  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

31 Virtual Round-Robin Diagram

32 Virtual Round-Robin Diagram

33 Virtual Round-Robin Diagram

34 Virtual Round-Robin Diagram

35 Virtual Round-Robin Diagram

36 Shortest Process Next (SPN) Selection function: the process with the shortest expected CPU burst time Decision mode: nonpreemptive I/O bound or short processes will be picked first  Possibility of starvation for longer processes We need to estimate the required processing time (CPU burst time) for each process

37 Estimating the required CPU burst 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 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] To avoid recalculating the entire sum we can rewrite this as:  S[n+1] = (1/n) T[n] + ((n-1)/n) S[n] But this convex combination gives equal weight to each instance

38 Estimating the required CPU burst But recent instances are more likely to reflect future behavior A common technique for that is to use exponential (moving) averaging  S[n+1] =  T[n] + (1-  ) S[n] ; 0 <  < 1  more weight is put on recent instances whenever  > 1/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

39 Exponentially Decreasing Coefficients

40 Use Of Exponential Averaging Here S[1] = 0 to give high priority to new processes Exponential averaging tracks changes in process behavior much faster than simple averaging

41 Shortest Process Next: critique Possibility of starvation for longer processes as long as there is a steady supply of shorter processes Lack of preemption is not suited in a time sharing environment  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 SPN implicitly incorporates priorities: shortest jobs are given preferences Preemptive version: Shortest Time Remaining

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

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

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

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

46 Fair Share Scheduling Previous algorithms treat all processes individually In a multiuser system, each user can own several processes (threads) Users belong to groups and each group should have its fair share of the CPU This is the philosophy of fair share scheduling Ex: If there are four groups, we could allocate 25% of processor to each (even if they have different number of processes)

47 The Fair Share Scheduler (FSS) Has been implemented on some Unix OS Processes are divided into groups Need to make scheduling decisions based on process sets Group k has a fraction Wk of the CPU The priority Pj[i] of process j (belonging to group k) at time interval i is given by:  Pj[i] = Bj + (1/2) CPUj[i-1] + GCPUk[i-1]/(4Wk)  A high value means a low priority  Process with highest priority is executed next  Bj = base priority of process j  CPUj[i] = Exponentially weighted average of processor usage by process j in time interval i  GCPUk[i] = Exponentially weighted average processor usage by group k in time interval i

48 The Fair Share Scheduler (FSS) The exponentially weighted averages use  = 1/2:  CPUj[i] = (1/2) Uj[i-1] + (1/2) CPUj[i-1]  GCPUk[i] = (1/2) GUk[i-1] + (1/2) GCPUk[i-1]  where  Uj[i] = processor usage by process j in interval i  GUk[i] = processor usage by group k in interval i Recall that  Pj[i] = Bj + (1/2) CPUj[i-1] + GCPUk[i-1]/(4Wk) The priority decreases as the process and group use the processor With more weight Wk, group usage decreases the priority

49 Fair-Share Scheduler

50 Fair-Share Scheduler

51 Fair-Share Scheduler

52 Fair-Share Scheduler

53 Fair-Share Scheduler

54 Fair-Share Scheduler

55 Traditional UNIX Scheduling Multilevel feedback using round robin within each of the priority queues If a running process does not block or complete within 1 second, it is preempted Priorities are recomputed once per second Base priority divides all processes into fixed bands of priority levels

56 Bands Decreasing order of priority  Swapper  Block I/O device control  File manipulation  Character I/O device control  User processes

57 Summary 3 types of scheduling  Long-term  Medium-term  Short-term Short-term Algorithms  FCFC, round robin, SPN, multilevel feedback, fair share Each system can have different criteria and require a different algorithm