From last lecture TDDC47: Concurrent and real-time programming Lecture 7: Scheduling III

advertisement
From last lecture
TDDC47: Concurrent and real-time
programming
Lecture 7: Scheduling III
Si i Nadjm-Tehrani
Simin
N dj
T h
i
Real-time Systems Laboratory
• Fixed priority scheduling can cause
priority inversion in presence of
resource sharing
• Dynamic priority inheritance is a way to
reduce
d
th
the bl
blocking
ki
time
ti
• Coming back to the deadlock related
problems...
Department of Computer and Information Science
Linköping University
Undergraduate course on Real-time Systems
Linköping University
9 pages
Autumn 2010
Undergraduate course on Real-time Systems
Linköping University
Example
2 of 9
Autumn 2010
Ceiling Protocols
e.g. Immediate priority Ceiling Protocol (ICP):
Let P1 have lower priority than P2.
Preemption
S1
P1
Blocked
S2?
S2
P2
Inheritance
S1?
Blocked
time
0
Here Si denotes the process locks semaphore Si.
Undergraduate course on Real-time Systems
Linköping University
3 of 9
Autumn 2010
Properties
• A process that obtains its first resource
inherits the resource’s ceiling priority - the
highest priority among all processes that can
possibly
p
y claim that resource
• Dynamic priority for a process is the max of
own (fixed) priority and the ceiling values of
all resources it has locked
• When a resource is released, the process
priority returns to the normal level (or to
another engaged resource’s ceiling)
Undergraduate course on Real-time Systems
Linköping University
4 of 9
Autumn 2010
Maximum blocking time
• The blocking delay is a function of the
length of the critical section
• When using immediate ceiling protocol
for any process Pi is given by Bi
• Do not even need to use semaphores!
• Bi : the max of times spent in different
critical sections for any resource shared
– by at least one process that has lower
priority than Pi and at least one
process with equal or higher priority
than Pi
• A process is blocked max once by
another process with lower priority
We will prove that!
Undergraduate course on Real-time Systems
Linköping University
5 of 9
Autumn 2010
Undergraduate course on Real-time Systems
Linköping University
6 of 9
Autumn 2010
1
ICP & Deadlock
• The ICP prevents deadlocks (How?)
• Moreover,, it prevents
p
starvation (How?)
(
)
Summing up CPU scheduling
• We have looked at one technique that is
time-driven (cyclic scheduling)
• We have looked at two techniques that
are event-driven (RMS and EDF)
– Both make on-line decisions based on arrival
of new processes
– One uses fixed priorities (RMS) and one
dynamic (EDF)
• We combined fixed priority scheduling
with dynamic (inherited) priorities to
deal with resource sharing
Undergraduate course on Real-time Systems
Linköping University
7 of 9
Autumn 2010
Undergraduate course on Real-time Systems
Linköping University
8 of 9
Autumn 2010
Next...
• We will look at real-time communication
• How to schedule a communication
channel as a resource
• Parallels with CPU scheduling: How to
guarantee that every message that uses
the channel meets its deadline?
Undergraduate course on Real-time Systems
Linköping University
9 of 9
Autumn 2010
2
Download