Uniprocessor Scheduling: William Stallings
Uniprocessor Scheduling: William Stallings
1/12/13
Roadmap
Scheduling
An OS must allocate resources amongst competing processes. The resource provided by a processor is execution time
The aim of processor scheduling is to assign processes to be executed by the processor over time,
in a way that meets system objectives, such as response time, throughput, and processor efficiency.
Scheduling Objectives
Share time fairly among processes Prevent starvation of a process Use the processor efficiently Have low overhead Prioritise processes when necessary (e.g. real time deadlines)
Types of Scheduling
Queuing Diagram
Long-Term Scheduling
May be first-come-first-served Or according to criteria such as priority, I/O requirements or expected execution time
Controls the degree of multiprogramming More processes, smaller percentage of time each process is executed
Medium-Term Scheduling
Part of the swapping function Swapping-in decisions are based on the need to manage the degree of multiprogramming
Short-Term Scheduling
Known as the dispatcher Executes most frequently Invoked when an event occurs
Roadmap
Main objective is to allocate processor time to optimize certain aspects of system behaviour. A set of criteria is needed to evaluate the scheduling policy.
Response Time
System-oriented
We could differentiate between performance related criteria, and those unrelated to performance Performance-related
Quantitative, easily measured E.g. response time and throughput Qualitative Hard to measure
Non-performance related
Priorities
Scheduler will always choose a process of higher priority over one of lower priority Have multiple ready queues to represent each level of priority
Priority Queuing
Starvation
Problem:
Lower-priority may suffer starvation if there is a steady supply of high priority processes.
Solution
Allow a process to change its priority based on its age or execution history
Selection Function
Determines which process is selected for execution If based on execution characteristics then important quantities are:
w = time spent in system so far, waiting e = time spent in execution so far s = total service time required by the process, including e;
Decision Mode
Specifies the instants in time at which the selection function is exercised. Two categories:
Nonpreemptive Preemptive
Nonpreemptive vs Premeptive
Non-preemptive
Once a process is in the running state, it will continue until it terminates or blocks itself for I/O Currently running process may be interrupted and moved to ready state by the OS Preemption may occur when new process arrives, on an interrupt, or periodically.
Preemptive
First-ComeFirst-Served
Each process joins the Ready queue When the current process ceases to execute, the longest process in the Ready queue is selected
First-ComeFirst-Served
A short process may have to wait a very long time before it can execute Favors CPU-bound processes
Round Robin
also known as time slicing, because each process is given a slice of time before being preempted.
Round Robin
Clock interrupt is generated at periodic intervals When an interrupt occurs, the currently running process is placed in the ready queue
Nonpreemptive policy Process with shortest expected processing time is selected next Short process jumps ahead of longer processes
Predictability of longer processes is reduced If estimated time for process not correct, the operating system may abort it Possibility of starvation for longer processes
Where:
Ti = processor execution time for the ith instance of this process Si = predicted value for the ith instance S1 = predicted value for first instance; not calculated
Exponential Averaging
A common technique for predicting a future value on the basis of a time series of past values is exponential averaging
Preemptive version of shortest process next policy Must estimate processing time and choose the shortest
Feedback Scheduling
Penalize jobs that have been running longer Dont know remaining time process needs to execute
Feedback Performance
Performance Comparison
Any scheduling discipline that chooses the next item to be served independent of service time obeys the relationship:
Formulas
Fair-Share Scheduling
Users application runs as a collection of processes (threads) User is concerned about the performance of the application Need to make scheduling decisions based on process sets
Fair-Share Scheduler
Roadmap
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 Priority is based on process type and execution history.
Scheduling Formula
Bands
Priorities are recomputed once per second Base priority divides all processes into fixed bands of priority levels
Swapper (highest) Block I/O device control File manipulation Character I/O device control User processes (lowest)