













Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!














Embedded and Autonomous Schedulers
Embedded and Autonomous Schedulers
Priority Scheduling
5 2 Scheduling Methods5.2 Scheduling Methods
A Framework for Scheduling
Common Scheduling Algorithms
g
g
Comparison of Methods
5.3 Priority Inversion
y
5.4 Multiprocessor and Distributed SchedulingCompSci 143A
Spring, 2009
h d li
Ready List (RL)
after creation
(Wh
d i
hi h
d
(When and in which order?)
CompSci 143A
Spring, 2009
p
i^
i^
i^
h
i
Dynamic priority: changes at runtime
p
at RL[
i ] run before
q
at RL[
j ] if
i>j
p
q
at same level are ordered by other criteria
CompSci 143A
Spring, 2009
Scheduler(){
d
{ do {
Find highest priority process p with p.status ==
ready_a
;
Find a free cpu;if (cpu != NIL) Allocate_CPU(p,cpu); } while (cpu != NIL);do {
Find highest priority process p with p.status ==
ready_a
;
Find lowest priority process q with p.status ==
running
;
if (Priority(p) > Priority(q)) Preempt(p,q); } while (Priority(p) > Priority(q));if (self->Status.Type!=’running’) Preempt(p,self); } CompSci 143A }
Spring, 2009
i^
d
i^
i^
a
r )
t )
d
e
CompSci 143A
Spring, 2009
Some Priority functions
CompSci 143A
Spring, 2009
-^
Like ML, but prioritychanges dynamically
g
y
y
-^
E
very process enters at highest level
n
-^
Each level P prescribesmaximum time
t
P
-^
tP
increases as P decreases tP
increases as P decreases
-^
Typically:
t^ n
= T
(a constant)
t^ P
= 2
×^
t^ P+
CompSci 143A
Figure 5-
Spring, 2009
MLF priority function:
Find
i^
for gi en
Find
= n–i
for
given
a
priority
attained time
n
a<T
n–
a<T+2T
n–
a<T+2T+4T
... ...
n–i
a<(
i+
–1)T
Find smallest
i
such that
a<(
i+
Solve for
i
i =
log
(a/T+1) 2
= n–i = n–
log
(a/T+1) 2
CompSci 143A
n i
n
⎣ log
(a/T 1) 2
Spring, 2009
FIFO, SJF, SRT: Primarily for batch systems– FIFO simplest
FIFO simplest
(r1+r2+…+rn)/n
Average turnaround times:Average
turnaround times:
FIFO: ((0+5) + (3+2))/2 = 5.0SRT: ((2+5) + (0+2))/ SRT: ((2+5) + (0+2))/2 = 4.
Figure 5-
CompSci 143A
13
Spring, 2009
Response time is critical
suitablesuitable
RR approaches FIFO
, RR approaches FIFO
0, context switch overhead
Wh
i^
h
t^
th
t^
t^
it h
overhead, n processes run concurrently at 1/nCPU speed
CompSci 143A
CPU speed
Spring, 2009
Example where RM fails
Figure 5-
CompSci 143A
Spring, 2009
Fi Figure 5-
-^
Assume priority order
p1>p2>p
-^
p
enters CS
;^ p
preempts
p
;^ p
preempts
p
;^
p
blocks on CS
-^
p
enters
CS;
p
preempts
p
;^ p
preempts
p
;^
p
blocks on CS
-^
Effect: process
p
,^ unrelated to
p
and of lower priority
, may
delay
p
1
indefinitely.
y^
p^
y
-^
Note: problem is not simply that
p
blocks. This is unavoidable.
The problem is that
p
is waiting on
p
.
CompSci 143A
17
-^
Problem would not occur if
p
in CS had priority greater than
p
Spring, 2009
Wh
i
i^
i^
d
i
When
p
is in its CS and
p
attempts to enter its
i h
it
(hi h
i^
it
f^
th
d
ti
p
inherits
p
’s (higher) priority for the duration
of CS
Figure 5-
CompSci 143A
Spring, 2009
Multiprocessor and Distributed Scheduling• Two Principle approaches
Single Scheduler
Single
Scheduler
M
ultiple Schedulers • Processors are divided into sets of separately schedulemachines, each with its own scheduler
,
group
Useful when different processors have differentcharacteristics and functions
CompSci 143A
Spring, 2009