EDA222/DIT160 – Real-Time Systems, Chalmers/GU, 2008/2009 Lecture #4
Updated 2009-01-25
1
Real Real-
- Time Systems
Time Systems
Verification Implementation Specification
- Ada 95
- Clocks, time, delay
- Task priorities
Real- -Time Systems Time Systems Real Ada 95 Specification - - PDF document
EDA222/DIT160 Real-Time Systems, Chalmers/GU, 2008/2009 Lecture #4 Updated 2009-01-25 Real- -Time Systems Time Systems Real Ada 95 Specification Clocks, time, delay Task priorities Implementation Verification Ada 95
with Ada.Calendar; use Ada.Calendar; package body Controller is task body Temp_Controller is ...
Start, Finish : Time; Interval : Duration := 1.7; Overrun_Error : exception; begin loop Start := Clock; ...
Finish := Clock; if Finish - Start > Interval then raise Overrun_Error; end if; end loop; exception when Overrun_Error =>
end Temp_Controller; end Controller;
with Ada.Real_Time; use Ada.Real_Time; package body Controller is task body Temp_Controller is ...
Start, Finish : Time; Interval : Time_Span := To_Time_Span(1.7); Overrun_Error : exception; begin loop Start := Clock; ...
Finish := Clock; if Finish - Start > Interval then raise Overrun_Error; end if; end loop; exception when Overrun_Error =>
end Temp_Controller; end Controller; Time constants have type Duration as default. Conversion of time intervals is found in Ada.Real_Time.
delay 10.0;
package body Periodic_Action is task body T is Interval : constant Duration := 5.0; begin loop Action; delay Interval; end loop; end T; end Periodic_Action;
– The code for Action takes a certain time Δaction – The code for administrating the loop construct takes a certain time Δloop ⇒ The minimum interval between two executions of Action is: 5 + Δaction + Δloop seconds.
delay until Later;
package body Periodic_Action is task body T is Interval : constant Duration := 5.0; Next_Time : Time; begin Next_Time := Clock + Interval; loop Action; delay until Next_Time; Next_Time := Next_Time + Interval; end loop; end T; end Periodic_Action;
– Other tasks with same or higher priority may interfere so that the task cannot begin its execution at the desired time instant – Local time skew may cause the start time within the current time interval to vary between different executions of the same task. – Local time skew can be avoided by using suitable scheduling algorithms or be determined with the aid of special analysis methods.
Any_Priority’First .. Any_Priority’Last
subtype Any_Priority is Integer range implementation-defined;
subtype Priority is Any_Priority range Any_Priority’First .. implementation-defined;
subtype Interrupt_Priority is Any_Priority range Priority’Last+1 .. Any_Priority’Last;
task P1 is pragma Priority(5); entry E1(X : in Objekt); entry E2(Y : out Objekt); end P1;
Default_Priority : constant Priority := (Priority’First + Priority’Last)/2;
package Ada.Dynamic_Priorities is procedure Set_Priority(...); function Get_Priority(...) return Any_Priority; end Ada.Dynamic_Priorities;
t1
H blocked
t2
Blocking time for H is not bounded by execution of critical region
H
M normal execution critical region
priority (H) > priority (M) > priority (L)
L
H and L share resource R
L receives R’s ceiling priority (= H’s priority) L receives original priority H blocked
H
M normal execution critical region
priority (H) > priority (M) > priority (L)
L
H and L share resource R
pragma Locking_Policy(Ceiling_Locking);