Upload
naumanahmed19
View
243
Download
0
Embed Size (px)
Citation preview
7/30/2019 Chapter09 New
1/58
Click to edit Master subtitle style
1/12/13
Chapter 9Uniprocessor Scheduling
Operating Systems:Internals and Design Principles, 6/EWilliam Stallings
Dave BremerOtago Polytechnic, N.Z.2008 Prentice Hall
7/30/2019 Chapter09 New
2/58
Roadmap
Types of Processor Scheduling Scheduling Algorithms Traditional UNIX Scheduling
7/30/2019 Chapter09 New
3/58
Scheduling
An OS must allocate resources amongstcompeting processes.
The resource provided by a processor is
execution time The resource is allocated by means of a
schedule
7/30/2019 Chapter09 New
4/58
Overall Aimof Scheduling
The aim of processor scheduling is toassign processes to be executed by theprocessor over time, in a way that meets system objectives, such
as response time, throughput, and processorefficiency.
7/30/2019 Chapter09 New
5/58
Scheduling Objectives
The scheduling function should Share time fairlyamong processes Prevent starvation of a process Use the processor efficiently Have low overhead Prioritise processes when necessary (e.g. real
time deadlines)
7/30/2019 Chapter09 New
6/58
Types of Scheduling
7/30/2019 Chapter09 New
7/58
Two Suspend States
Remember this diagram from Chapter 3
7/30/2019 Chapter09 New
8/58
Scheduling andProcess State Transitions
7/30/2019 Chapter09 New
9/58
Nesting ofScheduling Functions
7/30/2019 Chapter09 New
10/58
Queuing Diagram
7/30/2019 Chapter09 New
11/58
Long-Term Scheduling
Determines which programs are admittedto the system for processing 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 oftime each process is executed
7/30/2019 Chapter09 New
12/58
Medium-TermScheduling
Part of the swapping function Swapping-in decisions are based on the
need to manage the degree of
multiprogramming
7/30/2019 Chapter09 New
13/58
Short-Term Scheduling
Known as the dispatcher Executes most frequently Invoked when an event occurs
Clock interrupts I/O interrupts Operating system calls
Signals
7/30/2019 Chapter09 New
14/58
Roadmap
Types of Processor Scheduling Scheduling Algorithms Traditional UNIX Scheduling
7/30/2019 Chapter09 New
15/58
Aim of ShortTerm Scheduling
Main objective is to allocate processortime to optimize certain aspects of systembehaviour.
A set of criteria is needed to evaluate thescheduling policy.
7/30/2019 Chapter09 New
16/58
Short-Term SchedulingCriteria: User vs System
We can differentiate between user andsystem criteria
User-oriented Response Time
Elapsed time between the submission of a requestuntil there is output.
System-oriented Effective and efficient utilization of the
processor
7/30/2019 Chapter09 New
17/58
Short-Term SchedulingCriteria: Performance
We could differentiate betweenperformance related criteria, and thoseunrelated to performance
Performance-related Quantitative, easily measured E.g. response time and throughput
Non-performance related Qualitative Hard to measure
7/30/2019 Chapter09 New
18/58
InterdependentScheduling Criteria
7/30/2019 Chapter09 New
19/58
InterdependentScheduling Criteria cont.
7/30/2019 Chapter09 New
20/58
Priorities
Scheduler will always choose a process ofhigher priority over one of lower priority
Have multiple ready queues to represent
each level of priority
7/30/2019 Chapter09 New
21/58
Priority Queuing
7/30/2019 Chapter09 New
22/58
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
7/30/2019 Chapter09 New
23/58
Alternative SchedulingPolicies
7/30/2019 Chapter09 New
24/58
Selection Function
Determines which process is selected forexecution
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;
7/30/2019 Chapter09 New
25/58
Decision Mode
Specifies the instants in time at which theselection function is exercised.
Two categories: Nonpreemptive Preemptive
7/30/2019 Chapter09 New
26/58
Nonpreemptive vsPremeptive
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 interruptedand moved to ready state by the OS
Preemption may occur when new processarrives, on an interrupt, or periodically.
7/30/2019 Chapter09 New
27/58
Process SchedulingExample
Example set ofprocesses,
consider each abatch job
Service time represents total execution time
7/30/2019 Chapter09 New
28/58
First-Come-First-Served
Each process joins the Ready queue When the current process ceases to
execute, the longest process in the Ready
queue is selected
7/30/2019 Chapter09 New
29/58
First-Come-First-Served
A short process may have to wait a verylong time before it can execute
Favors CPU-bound processes I/O processes have to wait until CPU-bound
process completes
7/30/2019 Chapter09 New
30/58
Round Robin
Uses preemption based on a clock also known as time slicing, because each
process is given a slice of time before being
preempted.
7/30/2019 Chapter09 New
31/58
Round Robin
Clock interrupt is generated at periodicintervals
When an interrupt occurs, the currently
running process is placed in the readyqueue Next ready job is selected
7/30/2019 Chapter09 New
32/58
Effect of Size ofPreemption Time Quantum
7/30/2019 Chapter09 New
33/58
Effect of Size ofPreemption Time Quantum
7/30/2019 Chapter09 New
34/58
Virtual Round Robin
7/30/2019 Chapter09 New
35/58
Shortest Process Next
Nonpreemptive policy Process with shortest expected
processing time is selected next Short process jumps ahead of longer
processes
7/30/2019 Chapter09 New
36/58
Shortest Process Next
Predictability of longer processes isreduced
If estimated time for process not correct,
the operating system may abort it Possibility of starvation for longer
processes
7/30/2019 Chapter09 New
37/58
CalculatingProgram Burst
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; notcalculated
7/30/2019 Chapter09 New
38/58
Exponential Averaging
A common technique for predicting afuture value on the basis of a time seriesof past values is exponential averaging
7/30/2019 Chapter09 New
39/58
Exponential SmoothingCoefficients
Of
7/30/2019 Chapter09 New
40/58
Use Of ExponentialAveraging
U Of
7/30/2019 Chapter09 New
41/58
Use OfExponential Averaging
Sh t t R i i
7/30/2019 Chapter09 New
42/58
Shortest RemainingTime
Preemptive version of shortest processnext policy
Must estimate processing time and
choose the shortest
Hi h t R
7/30/2019 Chapter09 New
43/58
Highest ResponseRatio Next
Choose next process with the greatestratio
7/30/2019 Chapter09 New
44/58
Feedback Scheduling
Penalize jobs thathave been runninglonger
Dont knowremaining timeprocess needs to
execute
7/30/2019 Chapter09 New
45/58
Feedback Performance
Variations exist, simple version pre-emptsperiodically, similar to round robin But can lead to starvation
P f
7/30/2019 Chapter09 New
46/58
PerformanceComparison
Any scheduling discipline that chooses thenext item to be served independent ofservice time obeys the relationship:
7/30/2019 Chapter09 New
47/58
Formulas
O ll N li d
7/30/2019 Chapter09 New
48/58
Overall NormalizedResponse Time
N li d R
7/30/2019 Chapter09 New
49/58
Normalized ResponseTime for Shorter Process
N li d R
7/30/2019 Chapter09 New
50/58
Normalized ResponseTime for Longer Processes
N li d
7/30/2019 Chapter09 New
51/58
NormalizedTurnaround Time
7/30/2019 Chapter09 New
52/58
Fair-Share Scheduling
Users application runs as a collection ofprocesses (threads)
User is concerned about the performance
of the application Need to make scheduling decisions based
on process sets
7/30/2019 Chapter09 New
53/58
Fair-Share Scheduler
7/30/2019 Chapter09 New
54/58
Roadmap
Types of Processor Scheduling Scheduling Algorithms Traditional UNIX Scheduling
Traditional UNIX
7/30/2019 Chapter09 New
55/58
Traditional UNIXScheduling
Multilevel feedback using round robinwithin 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.
7/30/2019 Chapter09 New
56/58
Scheduling Formula
7/30/2019 Chapter09 New
57/58
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)
Example of Traditional
7/30/2019 Chapter09 New
58/58
Example of TraditionalUNIX Process Scheduling