Rate Monotonic Analysis

advertisement
Carnegie Mellon University
Software Engineering Institute
Rate Monotonic Analysis
Introduction
Periodic tasks
Extending basic theory
Synchronization and priority inversion
Aperiodic servers
Case Study: BSY-1 Trainer
1
Periodic Tasks
Carnegie Mellon University
Software Engineering Institute
A Sample Problem - Periodics
Periodics
Servers
Emergency
100 msec
τ1
50 msec
20 msec
Data Server
2 msec
150 msec
τ2
20 msec
5 msec
Deadline 6 msec
after arrival
40 msec
Comm Server
350 msec
τ3
Aperiodics
10 msec
10 msec
Routine
40 msec
2 msec
100 msec
Desired response
20 msec average
τ2’s deadline is 20 msec before the end of each period.
2
Periodic Tasks
Carnegie Mellon University
Software Engineering Institute
Concepts and Definitions - Periodics
Periodic task
• initiated at fixed intervals
• must finish before start of next cycle
Ci
Task’s CPU utilization: U i = ----Ti
• Ci = compute time (execution time) for task τi
• Ti = period of task τi
CPU utilization for a set of tasks:
U = U1 + U2 + … + Un
3
Periodic Tasks
Carnegie Mellon University
Software Engineering Institute
Example of Priority Assignment
Semantic-Based Priority Assignment
VIP:
IP:
0
25
misses deadline
10
20
30
20
30
Policy-Based Priority Assignment
IP:
0
10
VIP:
0
4
Periodic Tasks
25
1
10 = 0.10
11
VIP: UVIP = 25 = 0.44
IP:
0
UIP =
Carnegie Mellon University
Software Engineering Institute
Schedulability: UB Test
Utilization bound(UB) test: a set of n independent
periodic tasks scheduled by the rate monotonic
algorithm will always meet its deadlines, for all task
phasings, if
Cn
C1
------ + ... + ------- ≤ U(n) = n ( 2 1 / n – 1 )
Tn
T
1
U(1) = 1.0
U(2) = 0.828
U(3) = 0.779
U(4) = 0.756
U(5) = 0.743
U(6) = 0.734
U(7) = 0.728
U(8) = 0.724
U(9) = 0.720
For harmonic task sets, the utilization bound is
U(n)=1.00 for all n.
5
Periodic Tasks
Note: UB test = Techniques 1 and 2 in handbook.
Carnegie Mellon University
Software Engineering Institute
Sample Problem: Applying UB Test
Task τ1:
Task τ2:
Task τ3:
C
20
40
100
T
100
150
350
U
0.200
0.267
0.286
Total utilization is .200 + .267 + .286 = .753 < U(3) = .779
The periodic tasks in the sample problem are
schedulable according to the UB test.
6
Periodic Tasks
Carnegie Mellon University
Software Engineering Institute
Timeline for Sample Problem
0
100
200
τ1
τ2
τ3
Scheduling Points
7
Periodic Tasks
300
400
Carnegie Mellon University
Software Engineering Institute
Exercise: Applying the UB Test
Given:
Task
τ1
τ2
τ3
C
1
T
4
2
1
6
10
a. What is total utilization?
b. Is the task set schedulable?
c. Draw the timeline.
d. What is the total utilization if C3 = 2?
8
Periodic Tasks
U
Carnegie Mellon University
Software Engineering Institute
Toward a More Precise Test
UB test has three possible outcomes:
0 ≤ U ≤ U ( n ) ⇒ Success
U ( n ) < U ≤ 1.00 ⇒ Inconclusive
1.00 < U ⇒ Overload
UB test is conservative.
A more precise test can be applied.
10
Periodic Tasks
Carnegie Mellon University
Software Engineering Institute
Schedulability: RT Test
Theorem: for a set of independent, periodic tasks, if
each task meets its first deadline, with worst-case task
phasing, the deadline will always be met.
Response time (RT) test: let an = response time of task i.
an may be computed by the following iterative formula:
i–1 a
i
where a 0 = ∑ C j
a n + 1 = C i + ∑ -----n- C j
j=1
j = 1 Tj
Test terminates when an+1 = an.
Task i is schedulable if its response time is before its
deadline: an < Ti
11
Periodic Tasks
Carnegie Mellon University
Software Engineering Institute
Example: Applying RT Test -1
Taking the sample problem, we increase the compute
time of τ1 from 20 to 40; is the task set still schedulable?
Utilization of first two tasks: 0.667 < U(2) = 0.828
• first two tasks are schedulable by UB test
Utilization of all three tasks: 0.953 > U(3) = 0.779
• UB test is inconclusive
• need to apply RT test
12
Periodic Tasks
Carnegie Mellon University
Software Engineering Institute
Example: Applying RT Test -2
Use RT test to determine if τ3 meets its first deadline:
i=3
3
a0 =
∑ C j = C 1 + C 2 + C 3 = 40 + 40 + 100 = 180
j=1
i–1 a
2
a
0 C = C + ∑
0 C
=
C
+
∑
--------- j
1
i
j
3
j = 1 Tj
j = 1 Tj
180
= 100 + 180
--------- ( 40 ) + --------- ( 40 ) = 100 + 80 + 80 = 260
150
100
13
Periodic Tasks
Carnegie Mellon University
Software Engineering Institute
Example: Applying the RT Test -3
2
a1
260 ( 40 ) = 30
= C 3 + ∑ ------ C j = 100 + 260
+
(
40
)
----------------100
150
j = 1 Tj
2
a2
300
= C 3 + ∑ ------ C j = 100 + 300
--------- ( 40 ) + --------- ( 40 ) = 30
100
150
j = 1 Tj
a 3 = a 2 = 300
Done!
Task τ3 is schedulable using RT test.
a3 = 300 < T = 350
14
Periodic Tasks
Carnegie Mellon University
Software Engineering Institute
Timeline for Example
0
100
200
300
τ1
τ2
τ3
τ3 completes its work at t = 300
15
Periodic Tasks
Carnegie Mellon University
Software Engineering Institute
Exercise: Applying RT Test
Task τ1: C = 1 T = 4
1
1
Task τ2: C = 2 T = 6
2
2
Task τ3: C = 2 T = 10
3
a) Apply UB test
b) Draw timeline
c) Apply RT Test
16
Periodic Tasks
3
Carnegie Mellon University
Software Engineering Institute
Exercise: Worksheet
0
5
10
15
20
0
5
10
15
20
0
5
10
15
20
Task_____
Task_____
Task_____
17
Periodic Tasks
Carnegie Mellon University
Software Engineering Institute
Summary
UB test is simple but conservative.
RT test is more exact but also more complicated.
To this point, UB and RT tests share the same
limitations:
• all tasks run on a single processor
• all tasks are periodic and noninteracting
• deadlines are always at the end of the period
• there are no interrupts
• rate monotonic priorities are assigned
• there is zero context switch overhead
• tasks do not suspend themselves
19
Periodic Tasks
Download