From: slos <new.stephane.los@gmail.com>
Subject: Re: Ada and linux real time
Date: Sun, 18 Mar 2012 15:03:28 -0700 (PDT)
Date: 2012-03-18T15:03:28-07:00 [thread overview]
Message-ID: <dead35c2-e25b-46f7-8388-03f3853f2bf3@fk28g2000vbb.googlegroups.com> (raw)
In-Reply-To: m24ntnz0p8.fsf@pushface.org
I am learning Ada, don't laugh please ! ;-)
Here is mine :
with System;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Real_Time; use Ada.Real_Time;
procedure RT_test is
procedure cyclic is
real1 : Float := 10.0;
real2 : Float := 20.0;
real3 : Float := 0.0;
begin
for Index in 0 .. 1000000 loop -- should do something useful
instead
real3 := real1 * real2;
end loop;
end cyclic;
task type Periodic_Task
(Task_Priority : System.Priority;
Period_In_Milliseconds : Natural) is
pragma Priority (Task_Priority);
end Periodic_Task;
task body Periodic_Task is
Next_Time : Ada.Real_Time.Time := Clock;
MyPeriod : constant Time_Span := Milliseconds
(Period_In_Milliseconds);
Max_Times : Integer := 10000 / Period_In_Milliseconds; -- we
want the test to run 10 s
Times : Integer := 0;
Stats : array (1 .. 10) of Integer;
Thresholds : array (1 .. 10) of Duration;
MyDuration : Duration;
MyMinDuration : Duration;
MyMaxDuration : Duration;
MyPeriodDuration : Duration := To_Duration (MyPeriod);
begin
Put_Line ("MyPeriod_Duration : " & Duration'Image
(MyPeriodDuration));
for Index in Stats'Range loop
Stats (Index) := 0;
end loop;
Thresholds( 1) := MyPeriodDuration * 0.001;
Thresholds( 2) := MyPeriodDuration * 0.005;
Thresholds( 3) := MyPeriodDuration * 0.010;
Thresholds( 4) := MyPeriodDuration * 0.050;
Thresholds( 5) := MyPeriodDuration * 0.100;
Thresholds( 6) := MyPeriodDuration * 0.500;
Thresholds( 7) := MyPeriodDuration * 1.000;
Thresholds( 8) := MyPeriodDuration * 5.000;
Thresholds( 9) := MyPeriodDuration * 10.000;
Thresholds(10) := MyPeriodDuration * 20.000;
loop
Next_Time := Next_Time + MyPeriod;
cyclic; -- Do something useful
delay until Next_Time;
MyDuration := To_Duration (Clock - Next_Time);
if (Times = 0) then
MyMinDuration := MyDuration;
MyMaxDuration := MyDuration;
else
if MyMinDuration > MyDuration then
MyMinDuration := MyDuration;
else if MyMaxDuration < MyDuration then
MyMaxDuration := MyDuration;
end if;
end if;
end if;
for Index in Stats'Range loop
if MyDuration < Thresholds (Index) then
Stats (Index) := Stats (Index) + 1;
exit;
end if;
end loop;
Times := Times + 1;
exit when Times > Max_Times;
end loop;
Put_Line ("Et Hop ! Times : " & Times'Img & " Duration Min : " &
Duration'Image (MyMinDuration) & " Max : " & Duration'Image
(MyMaxDuration));
for Index in Stats'Range loop
Put_Line (Integer'Image(Index) & " | Thresholds := " &
Duration'Image(Thresholds(Index)) & " | Stats := " &
Integer'Image(Stats(Index)));
end loop;
Put_Line ("Periodic_Task finished !");
end Periodic_Task;
My_Periodic_Task : Periodic_Task (Task_Priority => 97,
Period_In_Milliseconds => 10);
begin
Put_Line ("Real Time test...");
end RT_test;
And the results don't tell me anything...
I have to think about putting some load on the system.
The test run for 10 s and outputs the difference between expected
sleep duration and actual, sorting the results in an array.
With no load either and no RT kernel :
Linux debian-sid 3.2.0-2-amd64 #1 SMP Tue Mar 13 16:54:04 UTC 2012
x86_64 GNU/Linux
/home/slos/Ada/NPLC/build/rt_test
Real Time test...
MyPeriod_Duration : 0.010000000
Et Hop ! Times : 1001 Duration Min : 0.000042000 Max : 0.000276000
1 | Thresholds := 0.000010000 | Stats := 0
2 | Thresholds := 0.000050000 | Stats := 1
3 | Thresholds := 0.000100000 | Stats := 560
4 | Thresholds := 0.000500000 | Stats := 440
5 | Thresholds := 0.001000000 | Stats := 0
6 | Thresholds := 0.005000000 | Stats := 0
7 | Thresholds := 0.010000000 | Stats := 0
8 | Thresholds := 0.050000000 | Stats := 0
9 | Thresholds := 0.100000000 | Stats := 0
10 | Thresholds := 0.200000000 | Stats := 0
Periodic_Task finished !
[2012-03-18 22:39:45] process terminated successfully (elapsed time:
10.12s)
next prev parent reply other threads:[~2012-03-18 22:06 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-06 21:19 Ada and linux real time slos
2012-03-07 8:23 ` Dmitry A. Kazakov
2012-03-07 12:10 ` slos
2012-03-07 14:18 ` Dmitry A. Kazakov
2012-03-08 2:38 ` Eilie
2012-03-08 8:27 ` Dmitry A. Kazakov
2012-03-08 12:04 ` Simon Clubley
2012-03-08 21:45 ` slos
2012-03-15 2:35 ` BrianG
2012-03-16 20:36 ` slos
2012-03-17 12:34 ` Simon Wright
2012-03-17 15:50 ` Simon Wright
2012-03-18 22:03 ` slos [this message]
2012-03-19 11:29 ` Georg Bauhaus
2012-03-19 13:01 ` Simon Wright
2012-03-19 13:12 ` slos
2012-03-19 13:30 ` slos
2012-03-19 13:35 ` Dmitry A. Kazakov
2012-03-19 16:11 ` slos
2012-03-19 17:55 ` Dmitry A. Kazakov
2012-03-19 22:20 ` slos
2012-03-20 8:04 ` Dmitry A. Kazakov
2012-03-19 13:20 ` Dmitry A. Kazakov
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox