Uniprocessor Scheduling Chapter 9. Processor Scheduling Processor scheduling determines the assignment of processes to be executed by the processor over.

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,
Ceng Operating Systems Chapter 2.2 : Process Scheduling Process concept  Process scheduling Interprocess communication Deadlocks Threads.
Day 25 Uniprocessor scheduling. Algorithm: Selection function Selection function – which process among ready processes to select. w – time spent in system,
Chapter 3: CPU Scheduling
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.
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. 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
Chapter 2.2 : Process Scheduling
Chapter 6: CPU Scheduling
Uniprocessor Scheduling
Uniprocessor scheduling
Operating System Chapter 9. Uniprocessor Scheduling
Chapter 9 Uniprocessor Scheduling
Operating System 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 4/11/2019.
Process Scheduling B.Ramamurthy 4/7/2019.
Uniprocessor scheduling
Uniprocessor Scheduling
Uniprocessor Scheduling
Presentation transcript:

Uniprocessor Scheduling Chapter 9

Processor Scheduling Processor scheduling determines the assignment of processes to be executed by the processor over time Goals of scheduling: –High processor utilization less idle time –Fast throughput large number of processes completed per unit time –Quick response time small elapsed time from the submission of a request to the beginning of the response –Fairness –Low overhead

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

Queuing Diagram for Scheduling

Long-Term Scheduling Determines which programs are admitted to the system for processing Controls the degree of multiprogramming Batch jobs: –Whether to create a new process? If more processes are admitted better CPU utilization - less likely that all processes will be blocked each process has smaller fraction of the CPU time –Which job to admit next? May be based on priority, I/O requirements, etc. The long term scheduler may attempt to keep a mix of processor-bound and I/O-bound processes

Long-Term Scheduling II Interactive programs: –E.g. user connecting to time-sharing system –Requests not queued up –Will accept new process requests until the system is saturated –When the system is full a new connection request is refused with an error message

Medium-Term Scheduling Swapping decisions based on the need to manage multiprogramming On systems with no virtual memory, the size of the process is also a criterion Done by memory management software and discussed in chapters 7 and 8

Short-Term Scheduling Determines which process is going to execute next (also called CPU scheduling) The short term scheduler is known as the dispatcher The scheduler is invoked whenever an event occurs that may lead to blocking or preemption of the current process. Example events: –clock interrupts –I/O interrupts –operating system calls –signals

Short-Term Scheduling Criteria Allocate processor time to optimize certain aspects of system behavior such as the following (Table 9.2) User-oriented criteria: perceived by a user or process –response time (interactive jobs), turn-around time (batch jobs) System-oriented criteria –processor utilization, throughput Performance-oriented (quantitative): readily measured –response time, throughput Non-performance-oriented (qualitative) –predictability, fairness Thus, the design of a scheduling policy involves compromising among several competing requirements and depends on the nature and use of the system

Definition of terms Turnaround time –Interval of time between the submission of a process and its completion Response time –Interval of time from submission of a request until the response begins to be received Throughput –Number of processes completed per unit time Processor utilization –Percentage of time the processor is busy Fairness –In the absence of priorities, processes should be treated the same; no process should starve

Using Priorities Implemented by having multiple ready queues to represent each level of priority Scheduler will always choose a process of higher priority over one of lower priority Problem: Lower-priority may suffer starvation Then 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 consider other algorithms that use dynamic priority mechanisms

Characteristics of Scheduling Policies The selection function: determines which process in the ready queue is selected next for execution The decision mode: specifies the instants in time at which the selection function is exercised –Non-preemptive 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 Greater overhead than non-preemptive ones

Process Arrival Time Service Time Service time = total processor time needed in one CPU-I/O cycle Or Service time = total execution time required Example to discuss various scheduling policies

Selection function: the process that has been waiting the longest in the ready queue (hence, FCFS); also known as FIFO Decision mode: non-preemptive –a process runs until it terminates or blocks itself First Come First Served (FCFS)

FCFS drawbacks A process that does not perform any I/O will monopolize the processor 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 more busy by giving a bit more priority to I/O bound processes FCFS is not an attractive policy on its own; combine with priority scheme

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 Round-Robin (Time Slicing)

Time Quantum for Round Robin Length of the time slice is the principal design issue for round robin Very short time quanta should be avoided because there is processing overhead involved in handling the clock interrupt and dispatching function Should be slightly larger than a typical interaction time to get good response time

Round Robin: Critique Effective in a time-sharing or transaction processing system 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 runs 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 (VRR) –When I/O is completed, the blocked process is moved to an auxiliary queue which has preference over the main 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

Queuing for Virtual Round Robin

Selection function: the process with the shortest expected processing time Decision mode: non-preemptive Short processes are moved ahead of longer jobs in the queue We need to estimate the required processing time (CPU burst time) for each process Shortest Process Next (SPN)

Simple averaging –T i : execution time for ith instance of this process (total execution time for batch job; processor burst time for interactive job) –S i : predicted value for ith instance –S 1 : predicted value for first instance; not calculated Estimating average CPU burst

Exponential averaging –S n+1 =  T n + (1 -  )S n (0  1) –S n+1 =  T n + (1 -  )  T n-1 + … + (1 -  ) i  T n-i + … + (1 -  ) n S 1 –when  is close to 1, weight is given to most recent observations quickly reflect rapid change in observed quantity –when  is smaller, the averaging is spread over several observations –Eg:  = 0.8 S n+1 = 0.8T n T n T n T n-3 + … –S 1 = 0 gives greater priority to new processes Estimating average CPU burst

S 1 = 0

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 for time sharing environments –CPU bound process gets lower priority (as it should) but a process doing no I/O could still monopolize the CPU if it is the first one to enter the system SPN implicitly incorporates priorities: shortest jobs are given preferences

Shortest Remaining Time (SRT) Selection function: the process with the shortest expected remaining processing time Decision mode: preemptive When a new process with a smaller remaining time enters the ready queue, the running process is preempted for the new process

Shortest Remaining Time: Critique Can be considered a preemptive version of SPN Does not have a bias for longer processes Risk of starvation of longer processes still exists As with SPN, need an estimate of processing time Also, elapsed service times must be recorded; adds overhead Gives better turnaround time than SPN because short jobs are given immediate preference

Highest Response Ratio Next (HRRN) Selection function: the process with largest value of response ratio (RR) –w: time spent waiting for the processor –s: expected service time Decision mode: non-preemptive

Highest Response Ratio Next: Critique Expected service time must be estimated as before Shorter jobs are favored because they have smaller denominator (larger ratio) Age of the process is also considered; therefore, longer jobs do get a chance to get past competing shorter jobs –waiting time for longer jobs increases, thus RR increases and the longer job gets scheduled

Multilevel Feedback Scheduling Preemptive scheduling (using time slices) with dynamic priorities Several ready to execute queues with decreasing priorities: P(RQ0) > P(RQ1) >... > P(RQn) A new process is placed in RQ0 When it is preempted (finishes its time quantum), it is placed in RQ1. Next time it is preempted it is placed in RQ2 and so on, until it reaches RQn I/O-bound (short) 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 longer jobs may starve

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

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 (RQi = 2 i ) Longer processes may still suffer starvation. Possible fix: promote a process to higher priority after some time Time Quantum for feedback Scheduling

Algorithm Comparison Which one is best? The answer depends on various factors such as –the system workload (extremely variable) –relative weighting of performance criteria (response time, CPU utilization, throughput...) Summary of algorithms: See –Table 9.3 –Table 9.5, Figure 9.5