from hrt-hood to ada95 [email protected] real-time systems lecture 5 copyright, 2001 ©...
TRANSCRIPT
From HRT-HOOD From HRT-HOOD to ADA95 to ADA95
Real-Time SystemsReal-Time Systems
Lecture 5Lecture 5
Copyright, 2001 © Adam Czajka
Copyright, 2001 © Adam Czajka
Contents
Introduction
HRT-HOOD objects
ADA95 mapping
Dynamic scheduling
Summary
Copyright, 2001 © Adam Czajka
Introduction
HRT-HOOD object types :
Pr B u f f e r
Put
* Get
Pr B u f f e r
Put
* Get
CyclicCyclic
SporadicSporadic
ProtectedProtected
PassivePassive
Copyright, 2001 © Adam Czajka
Introduction
Basic definitions:
TTijij – – jjthth instance of task T instance of task Tii
ii – execution time of task T – execution time of task Tii
ii – period of the task T – period of the task Tii
ijij – start time of the instance T – start time of the instance T ijij
ijij – finish time of the instance T – finish time of the instance T ijij
Copyright, 2001 © Adam Czajka
Introduction
Reference points for timing constraints
ss = = 1,21,2 - - 1,11,1 ee = = 1,21,2 - - 1,11,1
s
e
Copyright, 2001 © Adam Czajka
HRT-HOOD objects
Cyclic objects - attributes
PeriodPeriod
DeadlineDeadline
Execution timeExecution time
PriorityPriority
Copyright, 2001 © Adam Czajka
HRT-HOOD objects
Cyclic objects – strong periodicity
i,j+1i,j+1 - - i,ji,j = = ii
gdzie: gdzie: i, ji, j = 1, 2, 3, ... = 1, 2, 3, ...
i,1i,1 < < ii , , i,j+1i,j+1 > > i,ji,j
Copyright, 2001 © Adam Czajka
HRT-HOOD objects
Cyclic objects – weak periodicity
j*j*ii i,ki,k < < i,ki,k < < ((jj+1)*+1)*ii
gdzie: gdzie: i, ki, k = 1, 2, 3, ... = 1, 2, 3, ...
jj = 0, 1, 2, 3, ... = 0, 1, 2, 3, ...
Copyright, 2001 © Adam Czajka
HRT-HOOD objects
= < =
Cyclic objects – relative periodicity
i,j+1i,j+1 - - i,ji,j ii
gdzie: gdzie: i, ji, j = 1, 2, 3, ... = 1, 2, 3, ...
i,1i,1 < < ii , , i,j+1i,j+1 > > i,ji,j
Copyright, 2001 © Adam Czajka
HRT-HOOD objects
Sporadic objects - attributes
Minimum arrival timeMinimum arrival time
DeadlineDeadline
Execution timeExecution time
PriorityPriority
Copyright, 2001 © Adam Czajka
HRT-HOOD objects
Sporadic objects
Min. Arrival time Min. Arrival time
Cyclic object with period
Copyright, 2001 © Adam Czajka
HRT-HOOD objects
Sporadic objects
Sporadic objects are transformed
to cyclic ones.
Minimum arrival time = period
(worst case)
Conclusion :
Copyright, 2001 © Adam Czajka
ADA95 mappingADA95 mapping
Objects Objects ADA95 Packages ADA95 Packages
Cyclic objects Cyclic objects Tasks Tasks
Protected objects Protected objects Protected objects Protected objects
Passive objects Passive objects Simple packages Simple packages
Exceptions Exceptions ADA95 Exceptions ADA95 Exceptions
Rules of the mapping :
Copyright, 2001 © Adam Czajka
ADA95 mappingADA95 mapping
Cyclic objects
tasktask bodybody T Tii isis
beginbegin
looploop
next_time := next_time + next_time := next_time + ii; ;
................
delaydelay untiluntil next_time; next_time;
endend looploop;;
endend;;
Copyright, 2001 © Adam Czajka
ADA95 mappingADA95 mapping
Protected objects
protectedprotected body Pr body Pr isis
entryentry E E11 whenwhen .... ....
beginbegin
end;end;
eentryntry E E22 whenwhen .... ....
beginbegin
end;end;
endend;;
Copyright, 2001 © Adam Czajka
Dynamic schedulingDynamic scheduling
Liu & Layland approach (1973):
Rate Monotonic algorithmRate Monotonic algorithm
(fixed priorities)(fixed priorities)
EDF algorithmEDF algorithm
(dynamic priorities)(dynamic priorities)
Copyright, 2001 © Adam Czajka
Dynamic schedulingDynamic scheduling
Rate Monotonic algorithm
Set the tasks’ priorities according to Set the tasks’ priorities according to
the formula:the formula:
p p ii = 1 / = 1 / ii
Each time execute the task with the Each time execute the task with the
highest priorityhighest priority
Copyright, 2001 © Adam Czajka
Dynamic schedulingDynamic scheduling
Rate Monotonic algorithm
For the N tasks the utilization factor U is equal to:
Copyright, 2001 © Adam Czajka
Dynamic schedulingDynamic scheduling
Rate Monotonic algorithm
For a set of N tasks with fixed priority order, the least upper bound to processor utilization is
)12( /1 NNU
Copyright, 2001 © Adam Czajka
Dynamic schedulingDynamic scheduling
Rate Monotonic algorithm – ADA95 implementation
Tasks’ priorities are set by pragmaTasks’ priorities are set by pragma
pragmapragma priority(P priority(Pii))
We have 30 normal priorities and We have 30 normal priorities and
1 interrupt_priority (the highest one)1 interrupt_priority (the highest one)
Copyright, 2001 © Adam Czajka
Dynamic schedulingDynamic scheduling
Rate Monotonic algorithm – priority inversion
Pr1
T1
T2
T3
22 22
1111
33
11
33
Copyright, 2001 © Adam Czajka
Dynamic schedulingDynamic scheduling
Rate Monotonic algorithm – priority ceiling protocol
Pr1
T1
T2
T3
11
22
33
1133
Copyright, 2001 © Adam Czajka
Dynamic schedulingDynamic scheduling
Rate Monotonic algorithm – priority inversion in ADA95
We can prevent the priority inversion by We can prevent the priority inversion by
using the following pragma:using the following pragma:
pragmapragma Locking_Policy(Ceiling_Locking) Locking_Policy(Ceiling_Locking)
Copyright, 2001 © Adam Czajka
Dynamic schedulingDynamic scheduling
EDF algorithm
– the deadline driven scheduling approach
For the given moment of time, the For the given moment of time, the
priorities are assigned to the tasks priorities are assigned to the tasks
according to their current deadlines. according to their current deadlines.
A task will have the highest priority if its A task will have the highest priority if its
current deadline is the nearest. current deadline is the nearest.
Copyright, 2001 © Adam Czajka
Dynamic schedulingDynamic scheduling
EDF algorithm
– the deadline driven scheduling approach
For a given set of N tasks, the deadline driven scheduling algorithm is feasible if and only if
N
iii
1
1)/(
Copyright, 2001 © Adam Czajka
Dynamic schedulingDynamic scheduling
Implementation steps :
Write the codeWrite the code
Calculate the objects’ Calculate the objects’
attributesattributes
Set the tasks’ prioritiesSet the tasks’ priorities
Calculate the U-factorCalculate the U-factor