Download OperatingSystems-Lecture6

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Quantum electrodynamics wikipedia , lookup

Probability amplitude wikipedia , lookup

Transcript
Operating System Concepts and Techniques
Lecture 6
Scheduling-2*
M. Naghibzadeh
Reference
M. 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.
Analytical approach to scheduling
Modelling is one scientific approach to analytical
investigations
The following is a simple model of a uniprocessor
multiuser computing system
It is based on queuing methodology
User 1
User 2
Processor
User n
2
Interarrival distribution
Arrival and service patterns are often assumed to
obey Poisson distribution
It 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 queue
2. 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)
P0 (t  dt )  P0 (t )
Or
   P0 (t ) (6.3)
dt
The left side of equation (6.3) is the definition of the derivative
p 0 (t )
when dt approaches zero, thus:
P0 (t )

4
Interarrival distribution…
Or, from differential equations
n P (t )    t  c
0
But P0(0) = 1 , replacing t by zero in (6.4), we get:
P0 (t )  e
n P (0)     0  c
0
n P (t )    t
Which leads to c = 0, hence
Or
(6.4)
0
 t
 t
Or F(t) = 1 – P0(t) = 1 – e
probability density function (pdf) of the above distribution is:
f (t )  F  (t )   e   t
t >0,  > 0
(6.6)
5
Interarrival distribution…

1
The expected value is E (t )  0 t f (t )dt 

Hence, inter-arrival time is exponential and we expect to
receive a new arrival every 1time

Following a similar discussion shows the system
1
completes serving a request every  time
This argument shows there are highly analytical
arguments concerning many aspects of operating
system
6
Multiprocessor scheduling
Processor 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 parallelism
Assignment


static
dynamic
7
Multiprocessor schedulers
First-Come-First-Served
Shortest Job Next
Shortest Remaining Time Next
Fair-Share Scheduling
Round 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 scheduling
hard real-time system

Do it in time or catastrophe
soft real-time system

No catastrophe but inaccuracy
Request period



Periodic
Apriodic
Spradic
Most common hard real-times are periodic
10
Rate Monotonic (RM)
Periodic tasks
Static priority

A task with higher request rate, i.e., a
shorter request interval, is assigned a
higher priority
Safety verification



Safe if Ulub = n (21/n –1).
n
Where
U=  e i / ri
i 1
Optimal static priority for single processors
11
Earliest Deadline First (EDF)
Periodic tasks
Dynamic 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 priority
Works 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, Unpractical
Optimal dynamic priority
13
Summary
A 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 performance
Based on ATT different scheduling algorithms were
investigated
Besides, in this chapter, I/O scheduling was studied
and different schedulers such as FIFO, LIFO, SSTF,
Scan, and C-Scan were introduced
14
Find out
In a single-processor multi-programming How
average response time is computed
How many symmetric processors your laptop supports
Reasons behind processor affinity
Sample fine-grain parallelism applications
Reasons behind gang scheduling
Actual hard and soft real-time applications
Disadvantages of earliest deadline first scheduling
strategy
Systems which are not safe under RM but are safe
under relative urgency (RU)
15
Any questions?
16