From HRT-HOOD to ADA95 Real-Time Systems Lecture 5 Copyright, 2001 © Adam Czajka
Contents Introduction HRT-HOOD objects ADA95 mapping Dynamic scheduling Summary
Copyright, 2001 © Adam Czajka Introduction HRT-HOOD object types : Cyclic Cyclic Sporadic Sporadic Protected Protected Passive Passive
Copyright, 2001 © Adam Czajka Introduction Basic definitions: T ij – j th instance of task T i i – execution time of task T i i – period of the task T i ij – start time of the instance T ij ij – finish time of the instance T ij
Copyright, 2001 © Adam Czajka Introduction Reference points for timing constraints s = 1,2 - 1,1 e = 1,2 - 1,1 ss ee
Copyright, 2001 © Adam Czajka HRT-HOOD objects Cyclic objects - attributes Period Period Deadline Deadline Execution time Execution time Priority Priority
Copyright, 2001 © Adam Czajka HRT-HOOD objects Cyclic objects – strong periodicity i,j+1 - i,j = i gdzie: i, j = 1, 2, 3,... gdzie: i, j = 1, 2, 3,... i,1 i,j i,1 i,j
Copyright, 2001 © Adam Czajka HRT-HOOD objects Cyclic objects – weak periodicity j* i i,k < i,k < (j+1)* i j* i i,k < i,k < (j+1)* i gdzie: i, k = 1, 2, 3,... gdzie: i, k = 1, 2, 3,... j = 0, 1, 2, 3,... j = 0, 1, 2, 3,...
Copyright, 2001 © Adam Czajka HRT-HOOD objects == << == Cyclic objects – relative periodicity i,j+1 - i,j i gdzie: i, j = 1, 2, 3,... gdzie: i, j = 1, 2, 3,... i,1 i,j i,1 i,j
Copyright, 2001 © Adam Czajka HRT-HOOD objects Sporadic objects - attributes Minimum arrival time Minimum arrival time Deadline Deadline Execution time Execution time Priority Priority
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 mapping Objects ADA95 Packages Objects ADA95 Packages Cyclic objects Tasks Cyclic objects Tasks Protected objects Protected objects Protected objects Protected objects Passive objects Simple packages Passive objects Simple packages Exceptions ADA95 Exceptions Exceptions ADA95 Exceptions Rules of the mapping :
Copyright, 2001 © Adam Czajka ADA95 mapping Cyclic objects task body T i is begin loop loop next_time := next_time + i ; next_time := next_time + i ; delay until next_time; delay until next_time; end loop; end loop; end;
Copyright, 2001 © Adam Czajka ADA95 mapping Protected objects protected body Pr is entry E 1 when.... entry E 1 when.... begin begin end; end; entry E 2 when.... entry E 2 when.... begin begin end; end; end;
Copyright, 2001 © Adam Czajka Dynamic scheduling Liu & Layland approach (1973): Rate Monotonic algorithm (fixed priorities) EDF algorithm (dynamic priorities)
Copyright, 2001 © Adam Czajka Dynamic scheduling Rate Monotonic algorithm Set the tasks’ priorities according to the formula: p i = 1 / i Each time execute the task with the highest priority
Copyright, 2001 © Adam Czajka Dynamic scheduling Rate Monotonic algorithm For the N tasks the utilization factor U is equal to:
Copyright, 2001 © Adam Czajka Dynamic scheduling Rate Monotonic algorithm For a set of N tasks with fixed priority order, the least upper bound to processor utilization is
Copyright, 2001 © Adam Czajka Dynamic scheduling Rate Monotonic algorithm – ADA95 implementation Tasks’ priorities are set by pragma pragma priority(P i ) We have 30 normal priorities and 1 interrupt_priority (the highest one)
Copyright, 2001 © Adam Czajka Dynamic scheduling Rate Monotonic algorithm – priority inversion Pr 1 T1T1 T2T2 T3T
Copyright, 2001 © Adam Czajka Dynamic scheduling Rate Monotonic algorithm – priority ceiling protocol Pr 1 T1T1 T2T2 T3T
Copyright, 2001 © Adam Czajka Dynamic scheduling Rate Monotonic algorithm – priority inversion in ADA95 We can prevent the priority inversion by using the following pragma: pragma Locking_Policy(Ceiling_Locking)
Copyright, 2001 © Adam Czajka Dynamic scheduling EDF algorithm – the deadline driven scheduling approach For the given moment of time, the priorities are assigned to the tasks according to their current deadlines. A task will have the highest priority if its current deadline is the nearest.
Copyright, 2001 © Adam Czajka Dynamic 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
Copyright, 2001 © Adam Czajka Dynamic scheduling Implementation steps : Write the code Calculate the objects’ attributes Set the tasks’ priorities Calculate the U-factor
Copyright, 2001 © Adam Czajka Summary Introduction HRT-HOOD objects ADA95 mapping Dynamic scheduling