Operating System Concepts and Techniques Lecture 6 Scheduling-2* M. Naghibzadeh Reference M....
-
Upload
asher-collins -
Category
Documents
-
view
217 -
download
0
description
Transcript of Operating System Concepts and Techniques Lecture 6 Scheduling-2* M. Naghibzadeh Reference M....
Operating System Concepts and Techniques Lecture 6
Scheduling-2*
M. Naghibzadeh
ReferenceM. Naghibzadeh, Operating System Concepts and Techniques, First ed., iUniverse Inc., 2011.
To order: www.iUniverse.com, www.barnesandnoble.com, or www.amazon.com
* if your time table does not allow to cover all lectures, you can skip this lecture.
2
Analytical approach to schedulingModelling is one scientific approach to
analytical investigationsThe following is a simple model of a
uniprocessor multiuser computing systemIt is based on queuing methodology
User 1
User 2
User n
Processor
Interarrival distributionArrival and service patterns are often assumed
to obey Poisson distributionIt can be shown that if the following two
conditions satisfy the interarrival distribution is Poisson distribution
1. Arrival of new requests is independent of the history of the system and the current status of the
queue2. We can always define a time interval dt so small
that the probability of more than one arrival within any period (t, t+dt) is negligible. The probability of
one arrival in such an interval is equal to dt. Here, is a constant which is called arrival rate
3
Interarrival distribution…To show, let P0(t) represent the probability that there is no
arrival within the interval (0, t), then P0(t+dt) = Pr [ N(0, t+dt ) = 0]
= Pr [ N(0,t) = 0 AND N(t, t+dt) = 0].From Assumption 1, Pr [ N(0,t) = 0 AND N(t, t+dt) = 0]
= Pr [ N(0,t)=0] Pr [ N(t, t+dt) = 0] = P0(t) (1- dt).
Therefore, P0(t+dt) = P0(t) (1- dt)Or (6.3)
The left side of equation (6.3) is the definition of the derivative when dt approaches zero, thus:
4
)()()(
000 tP
dttPdttP
)()(
0
0
tPtp
Interarrival distribution…Or, from differential equations (6.4)
But P0(0) = 1 , replacing t by zero in (6.4), we get:
Which leads to c = 0, hence
Or
Or F(t) = 1 – P0(t) = 1 – probability density function (pdf) of the above distribution is:
t >0, > 0 (6.6)
5
cttPn )(0cPn 0)0(0
ttPn )(0tetP )(0
te
tetFtf )()(
Interarrival distribution…The expected value is
Hence, inter-arrival time is exponential and we expect to receive a new arrival every time
Following a similar discussion shows the system completes serving a request every time
This argument shows there are highly analytical arguments concerning many aspects of
operating system
6
1)()(
0
dttfttE
1
1
7
Multiprocessor schedulingProcessor types
Symmetric Multi-Processor (SMP); homogeneous system asymmetric multiprocessor; heterogeneous system
Processor Affinity hard affinity soft affinity
Synchronization Frequency Independent parallelism Coarse-grain parallelism
Fine-grain parallelismAssignment
static dynamic
Multiprocessor schedulersFirst-Come-First-Served
Shortest Job NextShortest Remaining Time Next
Fair-Share SchedulingRound Robin
Gang Scheduling, i.e., coscheduling
8
SMP Process Scheduling in Linux
For Symmetric Multi-Processor (SMP) Usually assign the processor which was used
last time There are preemptable and non-
preemptable processes Preempt if higher priority and hardware
cache rewrite time is less than time quantum
Respect processor affinty Uses SCHED_FIFO, SCHED_RR,
SCHED_OTHER
9
Real-time schedulinghard real-time system
Do it in time or catastrophesoft real-time system
No catastrophe but inaccuracyRequest period
Periodic Apriodic Spradic
Most common hard real-times are periodic
10
Rate Monotonic (RM)Periodic tasksStatic priority
A task with higher request rate, i.e., a shorter request interval, is assigned a
higher prioritySafety verification
Safe if Ulub = n (21/n –1). Where U=
Optimal static priority for single processors
11
n
1iii r/e
Earliest Deadline First (EDF)
Periodic tasksDynamic priority
Works like this: If the system has just started, picks the request
with the closest deadline The execution of a request is completed, a request with the closest deadline from ready queue is picked If the processor is running a process and a new
request with a closer deadline arrives, Process switching takes place
Optimal dynamic priority for single processor
12
Least Laxity First (LLF)Periodic tasks
Dynamic priorityWorks like this:
The laxity of a request at any given moment is the time span that it can tolerate before which time it has to be picked up for execution, i.e., L = D – T -
(E-C)Always run a task with least laxity
Disadvantage: for two processes with the equal and least, the processor has to continuously
switch between these two processes, UnpracticalOptimal dynamic priority
13
SummaryA scheduling strategy is usually designed to attain
a defined objective, although multi-objective strategies are also possible
Average turnaround time (ATT) may be used to estimate the expected time length in which a
request is completed after being submitted to the system. This could be a good measure of
performanceBased on ATT different scheduling algorithms were
investigatedBesides, in this chapter, I/O scheduling was studied
and different schedulers such as FIFO, LIFO, SSTF, Scan, and C-Scan were introduced
14
15
Find outIn a single-processor multi-programming How
average response time is computedHow many symmetric processors your laptop
supportsReasons behind processor affinity
Sample fine-grain parallelism applicationsReasons behind gang scheduling
Actual hard and soft real-time applicationsDisadvantages of earliest deadline first scheduling
strategySystems which are not safe under RM but are safe
under relative urgency (RU)
16
Any questions?