Introduction to Real-Time Systems
Note: Slides are adopted from Lui Sha and Marco Caccamo
1
Real-Time Systems Note: Slides are adopted from Lui Sha and Marco - - PowerPoint PPT Presentation
Introduction to Real-Time Systems Note: Slides are adopted from Lui Sha and Marco Caccamo 1 Recap Schedulability analysis - Determine whether a given real-time taskset is schedulable or not L&L least upper bound - Sufficient
Note: Slides are adopted from Lui Sha and Marco Caccamo
1
2
3
(useful chapters are in the Lab!): aperiodic tasks, background service and polling server.
4
Aperiodic task: runs at irregular intervals. Aperiodic task’s deadline can be
exponential inter-arrival time (Poisson Process)
exponential execution time
5
must convert the aperiodic event service into a periodic framework.
to periodically allocate CPU cycles to each stream of aperiodic requests. This CPU allocation is called “aperiodic server”:
6
Aperiodic tasks with hard deadline Soft aperiodic tasks
Periodic tasks ape soft
server ready queue Up
U1 U2
CPU
RM
Task set
server
7
periodic tasks causing deadline misses.
This works as well but the response time is not too good. For example:
8
3 6 9 10
T1 = (3,1) T2 = (5,2) Deadline miss
12 0.2 5 1.2 3 6 9 10
T1 = (3,1) T2 = (5,2)
12 5 3 6 9 10
T1 = (3,1) T1 = (5,2)
12 5
S = (2.5,0.5)
2.5 5 7.5 10 12.5
Interrupt Handling
Background Polling
9
to wait for the beginning of next period before being served.
10
periodic tasks is easy to analyze. For example, if we use L&L bound,
) 1 /( 1 1
n s s n i i i
11
priority just like periodic tasks)
next period with a new C budget again.
CS 431 12
13
Polling Server with P=100
100
...
Average service delay = 50 units
...
Service delay of a polling server is, on average, roughly half of the server period.
time.
200 300 400 500
Arrival of aperiodic task
14
interrupt handlers run at priority higher than applications
deadlines of periodic tasks to be missed.
hard deadline aperiodic requests such as power failure warning.
... ...
Service delay: negligible
Interrupt Handler
15
each server period, SS replenishes its capacity only after it has been consumed by aperiodic task execution.
However, SS has better response time than Polling server.
delay almost equivalent to an interrupt handler but without causing the deadline miss
16
another task with priority PrioTPrios is executing. Hence, the server remains active even when it is preempted by a higher priority task.
capacity Cs>0. Let TA be such a time. The value of RT is set equal to TA plus the server period (RT= TA+ ps).
becomes idle or the server capacity Cs has been exhausted. Let TI be such a time. The value of RA is set equal to the capacity consumed within the interval [TA, TI].
CS 431 17
C p T1 1 5 TS 5 10 T2 4 15
18
C p TS 2 8 T1 3 10 T2 4 15
19
aperiodic requests are pending. This allows SS to achieve better response time compared to Polling Server.
In other words, Sporadic Server behaves like a regular periodic task, so nothing changes when you check the schedulability of the task set.
20
(without using background)
0 6 12 2 1 T1 T2 TS aperiodic requests
21
using background)
X X X X X X X X X X 0 6 12 2 1 T1 T2 TS aperiodic requests
22
using background)
X X X X X X X X X X 0 6 12 2 1 T1 T2 TS aperiodic requests
23
24
OK!
FAILED!
) 2 ( 45 .
1 1
U P C P C
s s
779 . ) 3 ( 784 .
2 2 1 1
U P C P C P C
s s
25
26
r2
0 = 1+1+2 = 4,
r2
1 = ceil(4/4)*1 + ceil(4/5)*1 + 2 = 4 < 6
The lowest priority task T2 is schedulable!! Hence, the all task set is schedulable!
27
28
29
Suppose task , with computation time C and period P, has a relative deadline D < P.
(C+ ), because if the task has execution time (C+ ) and can finish before time P, then we know it must finish units before P if it has only execution time C.
C deadline P
=P-D
D
30
execution time LOCALLY (Why?)
2 2 2 1 1 2
priority task in the system!
3 3 2 2 1 1 3
1 1 1
31
2
2
because the pre-period deadline of a task does not affect the schedulability of other tasks!
have N tasks, you need to check N equations to verify the schedulability of the all task set (The original UB studied in lecture 18 allowed to check the schedulability of the all task set by checking a single equation!!!).
2’s execution time LOCALLY (Why?) T1 T2 T3
32
Given the following tasks:
C p D Task 1 1 4 Task 2 2 6 5 Task 3 2 10
Assume S = 0.05, are these 3 tasks schedulable?
33
00 . 1 ) 1 ( 275 . 4 )) 05 . ( 2 (1
1
U 828 . ) 2 ( 791 . 6 ) 1 ) 05 . ( 2 (2 4 )) 05 . ( 2 (1
2
U
779 . ) 3 ( 835 . 10 )) 05 . ( 2 (2 35 . .275
3
U
Exact analysis: r3
0 = 1.1 + 2.1 + 2.1 = 5.3
r3
1 = 2.1 + ceil(5.3/4) * 1.1 + ceil(5.3/6) * 2.1 = 6.4
r3
2 = 2.1 + ceil(6.4/4) * 1.1 + ceil(6.4/6) * 2.1 = 8.5
r3
3 = 2.1 + ceil(8.5/4) * 1.1 + ceil(8.5/6) * 2.1 = 9.6
r3
4 = 2.1 + ceil(9.6/4) * 1.1 + ceil(9.6/6) * 2.1 = 9.6
Task 3 is schedulable, it completes by 10!
j i j j k i i k i
c p r c r
1 1 1
34
long period task is delayed by the execution of short period tasks, the long period task is said to be PREEMPTED by short period tasks.
short period (high-priority) tasks? In this case, the short period (high-priority) task is said to be BLOCKED by long period (low-priority) tasks.
called preemption, independent of periods.)
35
priority to reduce jitter. As a result, 3’s data I/O blocks the execution of shorter period tasks 1 and 2. Data I/O 3 I/O 1 2 3 exec
will have higher priority even if it is done for a longer period task
36
the task has a longer execution time (C+B).
1. When using utilization test, we need to adjust the task utilization: so we inflate ci to (ci + Bi + i) and check if the task is still schedulable. Suppose that task 2 has B2 as blocking time, we just add B2 to task T2’s execution time LOCALLY 2. When using exact analysis, we inflate ci to (ci + Bi) and check if the finishing time
This term models the blocking time
i j j i i j i j j k i i i k i
1 1 1 1
37
add (B+(P-D)) to its execution time when using UB test (remember to inflate execution time LOCALLY). In exact schedulability test, we will inflate the execution time by B and move the deadline from P to D.
) 1 ( ) 2 (C
1 1 1 1 1 1
U P B D P S ) 2 ( ) 2 (C ) 2 (C
2 2 2 2 2 1 1 2
U P B D P S P S ) 3 ( ) 2 (C ) 2 (C ) 2 (C
3 3 3 3 2 2 1 1 3
U P D P S P S P S
Note that B3 is always zero. 3 is the task with the longest period and therefore it cannot be blocked by a task with longer period.
38
C T B D Task t1 1 4 ? Task t2 1 6 ? Task t3 4 13 ? 12
Suppose that S=0. However, task 3 has two parts. part 1 has execution time C3=1; part 2 is 3 units long and does I/O operations. To reduce jitter, part 2 is executed with the highest priority in the system. Fill in the blocking times in the table and determine if all three tasks are schedulable?
39
C T B D Task t1 1 4 ? Task t2 1 6 ? Task t3 4 13 ? 12
40
C P B D Task t1 1 4 3 Task t2 1 6 3 Task t3 4 13 0 12
00 . 1 ) 1 ( 00 . 1 4 ) 3 (1
1
U
2
a0 = 1 + 1 + 3 = 5
Utilization Bound with blocking and/or pre-preriod deadlines becomes a task by task test: if you have N tasks, you need to check N equations to verify the schedulability of all the task set (The original formulation studied in lecture 18 allowed to check the schedulability of all task set with a single test!!!).
Check with exact analysis!
a1 = 1 + 3 + ceil(5/4)*1 = 6 a2 = 1 + 3 + ceil(6/4)*1 = 6 schedulable
41
C P B D Task t1 1 4 3 Task t2 1 6 3 Task t3 4 13 0 12
3
a0 = 1+1+4 = 6, a1 = ceil(6/4)*1 + ceil(6/6)*1 + 4 = 7 a2 = ceil(7/4)*1 + ceil(7/6)*1 + 4 = 8 a3 = ceil(8/4)*1 + ceil(8/6)*1 + 4 = 8 < 12 The lowest priority task is schedulable!!
42
C P B D Task t1 26 59 59 Task t2 10 60 4 50 Task t3 25 155 5 135 Task t4 15 210 0 180
2S = 1
2
a0 = 11+ 4 + 27 = 42 a1 = 11 + 4 + ceil(42/59)*27 = 42 schedulable It failed, check with exact test
43
C P B D Task t1 26 59 59 Task t2 10 60 4 50 Task t3 25 155 5 135 Task t4 15 210 0 180
Don’t stop! Check with exact analysis even if total load is
pre-period deadline is not real execution time. 2S = 1
a0 = 26+ 5 + 27 + 11 = 69 a1 = 26 + 5 + ceil(69/59)*27 + ceil(69/60)*11 = 107 a2 = 26 + 5 + ceil(107/59)*27 + ceil(107/60)*11 = 107 schedulable
44
C P B D Task t1 26 59 59 Task t2 10 60 4 50 Task t3 25 155 5 135 Task t4 15 210 0 180
2S = 1
a0 = 16+ 27 + 11 + 26 = 80 a1 = 16 + ceil(80/59)*27 + ceil(80/60)*11 + ceil(80/155)*26 = 118 a2 = 16 + ceil(118/59)*27 + ceil(118/60)*11 + ceil(118/155)*26 = 118 schedulable