comp.lang.ada
 help / color / mirror / Atom feed
* Ada and linux real time
@ 2012-03-06 21:19 slos
  2012-03-07  8:23 ` Dmitry A. Kazakov
  0 siblings, 1 reply; 23+ messages in thread
From: slos @ 2012-03-06 21:19 UTC (permalink / raw)


Hello there,

I am running Debian Sid and have installed the linux real time kernel
available through synaptic :
linux-image-3.2.0-2-rt-amd64
Linux 3.2 for 64-bit PCs, PREEMPT_RT

I am learning Ada from good books but none is talking about running
real time Ada programs on that platform although it seems to me an
obvious choice, Mister Brenta doing a nice job here putting every
needed Ada things together.

But what about the gnat runtime stuff ? Is it sufficient to use that
RT kernel in order to have RT behaviour or is it necessary to obtain a
specific runtime from Adacore ?

I have tried some code on both RT and non RT kernels but was not
impressed by the difference.

I am trying to write some GPLed application so don't expect to sell me
anything.

Thank you for your kind support.
BR
Stéphane



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Ada and linux real time
  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
  0 siblings, 1 reply; 23+ messages in thread
From: Dmitry A. Kazakov @ 2012-03-07  8:23 UTC (permalink / raw)


On Tue, 6 Mar 2012 13:19:24 -0800 (PST), slos wrote:

> I have tried some code on both RT and non RT kernels but was not
> impressed by the difference.

What kind of difference you expected to see?

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Ada and linux real time
  2012-03-07  8:23 ` Dmitry A. Kazakov
@ 2012-03-07 12:10   ` slos
  2012-03-07 14:18     ` Dmitry A. Kazakov
  0 siblings, 1 reply; 23+ messages in thread
From: slos @ 2012-03-07 12:10 UTC (permalink / raw)


On 7 mar, 09:23, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
wrote:
> On Tue, 6 Mar 2012 13:19:24 -0800 (PST), slos wrote:
> > I have tried some code on both RT and non RT kernels but was not
> > impressed by the difference.
>
> What kind of difference you expected to see?
>
> --
> Regards,
> Dmitry A. Kazakovhttp://www.dmitry-kazakov.de

I can't post the code from the place I am, so I will just describe it.

My little test schedules a periodic task with a period of let's say
10ms.

The periodic task then calls the Ada.Real_Time.Clock and measures the
difference to the scheduled time.
The difference is stored in an array of durations where each index
correspond to an interval.
Difference < 0.1 * period
Difference < 0.2 * period
Difference < 0.5 * period
Difference < 1.0 * period
etc...
The purpose is to characterise the scheduling.
Running the program for a while I get an image of how it behaves.
Using both RT and non RT kernels give about same finding.
Thousands are correct while some are clearly out of specified period.
And I have not put any load on the system yet.

I plan to use tools provided by OSADL to stress the system but of
course it means nothing if I need some real time Ada runtime to
achieve real time performance and can't get it for free.

BR
Stéphane



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Ada and linux real time
  2012-03-07 12:10   ` slos
@ 2012-03-07 14:18     ` Dmitry A. Kazakov
  2012-03-08  2:38       ` Eilie
  0 siblings, 1 reply; 23+ messages in thread
From: Dmitry A. Kazakov @ 2012-03-07 14:18 UTC (permalink / raw)


On Wed, 7 Mar 2012 04:10:14 -0800 (PST), slos wrote:

> On 7 mar, 09:23, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
> wrote:
>> On Tue, 6 Mar 2012 13:19:24 -0800 (PST), slos wrote:
>>> I have tried some code on both RT and non RT kernels but was not
>>> impressed by the difference.
>>
>> What kind of difference you expected to see?
> 
> I can't post the code from the place I am, so I will just describe it.
> 
> My little test schedules a periodic task with a period of let's say
> 10ms.

I see.

The problem is likely not in the Ada's RTL but in the OS. Usually Ada
(specifically GNAT) maps tasks onto OS-native threads. You should look
after the OS settings which control scheduling. These are OS specific, but
10ms looks quite plausible.

> The periodic task then calls the Ada.Real_Time.Clock and measures the
> difference to the scheduled time.

Ada.Real_Time.Clock would typically use the OS time services, which,
frequently have very low accuracy. In order to check a particular OS, call
Ada.Real_Time.Clock several times and compare the results.

I cannot tell for Linux, because I didn't use it for real-time purposes
yet. Ideally it should derive the system time from the TSC. However
scheduling would likely limited when controlled by timer interrupts. The
minimal waiting time is then determined by the timer's period. You should
look for this kernel setting if you want go below 10ms, or what the actual
limit is.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Ada and linux real time
  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
  0 siblings, 2 replies; 23+ messages in thread
From: Eilie @ 2012-03-08  2:38 UTC (permalink / raw)


On 2012-03-07, Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> wrote:
> On Wed, 7 Mar 2012 04:10:14 -0800 (PST), slos wrote:
>
> I cannot tell for Linux, because I didn't use it for real-time purposes
> yet. Ideally it should derive the system time from the TSC. However
> scheduling would likely limited when controlled by timer interrupts. The
> minimal waiting time is then determined by the timer's period. You should
> look for this kernel setting if you want go below 10ms, or what the actual
> limit is.
>

And what OS do you use for real-time purposes?



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Ada and linux real time
  2012-03-08  2:38       ` Eilie
@ 2012-03-08  8:27         ` Dmitry A. Kazakov
  2012-03-08 12:04         ` Simon Clubley
  1 sibling, 0 replies; 23+ messages in thread
From: Dmitry A. Kazakov @ 2012-03-08  8:27 UTC (permalink / raw)


On Thu, 8 Mar 2012 02:38:53 +0000 (UTC), Eilie wrote:

> On 2012-03-07, Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> wrote:
>> On Wed, 7 Mar 2012 04:10:14 -0800 (PST), slos wrote:
>>
>> I cannot tell for Linux, because I didn't use it for real-time purposes
>> yet. Ideally it should derive the system time from the TSC. However
>> scheduling would likely limited when controlled by timer interrupts. The
>> minimal waiting time is then determined by the timer's period. You should
>> look for this kernel setting if you want go below 10ms, or what the actual
>> limit is.
> 
> And what OS do you use for real-time purposes?

Don't get me wrong, It just happened that I am using VxWorks. But I am sure
it is possible to achieve 1ms or 0.1ms cycles under Linux too.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Ada and linux real time
  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
  1 sibling, 1 reply; 23+ messages in thread
From: Simon Clubley @ 2012-03-08 12:04 UTC (permalink / raw)


On 2012-03-07, Eilie <Eilie@what-are-you-looking.for> wrote:
> On 2012-03-07, Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> wrote:
>> On Wed, 7 Mar 2012 04:10:14 -0800 (PST), slos wrote:
>>
>> I cannot tell for Linux, because I didn't use it for real-time purposes
>> yet. Ideally it should derive the system time from the TSC. However
>> scheduling would likely limited when controlled by timer interrupts. The
>> minimal waiting time is then determined by the timer's period. You should
>> look for this kernel setting if you want go below 10ms, or what the actual
>> limit is.
>>
>
> And what OS do you use for real-time purposes?

Look at RTEMS. It has Ada support built in.

I recommend you read through the online documentation first to decide if
it's suitable for you.

Start at http://www.rtems.com/

Simon.

-- 
Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP
Microsoft: Bringing you 1980s technology to a 21st century world



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Ada and linux real time
  2012-03-08 12:04         ` Simon Clubley
@ 2012-03-08 21:45           ` slos
  2012-03-15  2:35             ` BrianG
  0 siblings, 1 reply; 23+ messages in thread
From: slos @ 2012-03-08 21:45 UTC (permalink / raw)


On 8 mar, 13:04, Simon Clubley <clubley@remove_me.eisner.decus.org-
Earth.UFP> wrote:
> On 2012-03-07, Eilie <Ei...@what-are-you-looking.for> wrote:
>
> > On 2012-03-07, Dmitry A. Kazakov <mail...@dmitry-kazakov.de> wrote:
> >> On Wed, 7 Mar 2012 04:10:14 -0800 (PST), slos wrote:
>
> >> I cannot tell for Linux, because I didn't use it for real-time purposes
> >> yet. Ideally it should derive the system time from the TSC. However
> >> scheduling would likely limited when controlled by timer interrupts. The
> >> minimal waiting time is then determined by the timer's period. You should
> >> look for this kernel setting if you want go below 10ms, or what the actual
> >> limit is.
>
> > And what OS do you use for real-time purposes?
>
> Look at RTEMS. It has Ada support built in.
>
> I recommend you read through the online documentation first to decide if
> it's suitable for you.
>
> Start athttp://www.rtems.com/
>
> Simon.
>
> --
> Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP
> Microsoft: Bringing you 1980s technology to a 21st century world

Hi,

Thank you for your answers.

I know RTEMS and MarteOS and they are great projects.

But I want to use the stuff those guys have put in the kernel main
line :
https://www.osadl.org/HOWTOs.howtos.0.html

It may not be the most accurate or performance may be lower than with
other solutions but I think it would match my needs for now.
Of course, if I can run Ada and get something "real time".
Otherwise, my project is quite useless.

BR
Stéphane



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Ada and linux real time
  2012-03-08 21:45           ` slos
@ 2012-03-15  2:35             ` BrianG
  2012-03-16 20:36               ` slos
  0 siblings, 1 reply; 23+ messages in thread
From: BrianG @ 2012-03-15  2:35 UTC (permalink / raw)


On 03/08/2012 04:45 PM, slos wrote:
> On 8 mar, 13:04, Simon Clubley<clubley@remove_me.eisner.decus.org-
> Earth.UFP>  wrote:
>> On 2012-03-07, Eilie<Ei...@what-are-you-looking.for>  wrote:
>>
>>> On 2012-03-07, Dmitry A. Kazakov<mail...@dmitry-kazakov.de>  wrote:
>>>> On Wed, 7 Mar 2012 04:10:14 -0800 (PST), slos wrote:
>>
>>>> I cannot tell for Linux, because I didn't use it for real-time purposes
>>>> yet. Ideally it should derive the system time from the TSC. However
>>>> scheduling would likely limited when controlled by timer interrupts. The
>>>> minimal waiting time is then determined by the timer's period. You should
>>>> look for this kernel setting if you want go below 10ms, or what the actual
>>>> limit is.
>>
>>> And what OS do you use for real-time purposes?
>>
>> Look at RTEMS. It has Ada support built in.
>>
>> I recommend you read through the online documentation first to decide if
>> it's suitable for you.
>>
>> Start athttp://www.rtems.com/
>>
>> Simon.
>>
>> --
>> Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP
>> Microsoft: Bringing you 1980s technology to a 21st century world
>
> Hi,
>
> Thank you for your answers.
>
> I know RTEMS and MarteOS and they are great projects.
>
> But I want to use the stuff those guys have put in the kernel main
> line :
> https://www.osadl.org/HOWTOs.howtos.0.html
>
> It may not be the most accurate or performance may be lower than with
> other solutions but I think it would match my needs for now.
> Of course, if I can run Ada and get something "real time".
> Otherwise, my project is quite useless.
>
> BR
> St�phane

I've had a test program similar to what you describe, except I dumped 
the sequence of times, rather than statistics.  I've had it since DOS 
was the active PC version of GNAT (3.10 or such), and occasionally look 
at the results on different platforms/versions.  From what I've seen, 
performance on Linux (using standard-out-of-box non-RT versions) varies 
significantly depending on the distribution.  I'd have to look, but I 
think Knoppix (at the time, maybe 3.6) had surprisingly good results, 
compared to Red Hat, etc.  I assumed it was due the standard background 
processes they had (or didn't have) running.

Of course, my standard test was with a 1 second clock (just a generic 
timer test, not looking for RT-like performance).  I looked at other 
values, but don't remember the results of small values.

-- 
---
BrianG
000
@[Google's email domain]
.com



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Ada and linux real time
  2012-03-15  2:35             ` BrianG
@ 2012-03-16 20:36               ` slos
  2012-03-17 12:34                 ` Simon Wright
  0 siblings, 1 reply; 23+ messages in thread
From: slos @ 2012-03-16 20:36 UTC (permalink / raw)


Hi Brian,

Thank you for your input.

Hi list,

I have downloaded gnat-gpl-2011-src and tried to see if there was
something that I could identify as a Linux RT runtime and I have found
some files connected to various OSes but nothing that seemed related
to Linux RT.
I have seen some Xenomai, MarteOS, RTEMS stuff but well... still
looking for that simple alternative, the kernel with the PREMPT RT
patches.
Although it may be less suitable than counterparts for high
performance systems I think it deserves some attention from the Ada
crowd isn't it ?

So I am willing to help here if I can but could someone point me to
any available documentation on how to proceed or even give some
advice ?

Don't anyone think it could increase Ada's audience ?

I've been told that Ada is a niche language which target is among
others Real Time applications.
Is the niche shrinking ? I hope no.

BR
Stéphane



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Ada and linux real time
  2012-03-16 20:36               ` slos
@ 2012-03-17 12:34                 ` Simon Wright
  2012-03-17 15:50                   ` Simon Wright
  0 siblings, 1 reply; 23+ messages in thread
From: Simon Wright @ 2012-03-17 12:34 UTC (permalink / raw)


slos <new.stephane.los@gmail.com> writes:

> I have downloaded gnat-gpl-2011-src and tried to see if there was
> something that I could identify as a Linux RT runtime and I have found
> some files connected to various OSes but nothing that seemed related
> to Linux RT.

> I have seen some Xenomai, MarteOS, RTEMS stuff but well... still
> looking for that simple alternative, the kernel with the PREMPT RT
> patches.

> Although it may be less suitable than counterparts for high
> performance systems I think it deserves some attention from the Ada
> crowd isn't it ?
>
> So I am willing to help here if I can but could someone point me to
> any available documentation on how to proceed or even give some advice
> ?

I was under the impression that the PREEMPT RT kernel "just" made the
standard primitives more predictable & hence suitable for RT.

I found http://pengutronix.de/software/linux-rt/debian_en.html and was
going to have a go, but it looks as though they only support sid and I
don't plan to update just yet!



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Ada and linux real time
  2012-03-17 12:34                 ` Simon Wright
@ 2012-03-17 15:50                   ` Simon Wright
  2012-03-18 22:03                     ` slos
  0 siblings, 1 reply; 23+ messages in thread
From: Simon Wright @ 2012-03-17 15:50 UTC (permalink / raw)


Simon Wright <simon@pushface.org> writes:

> I was under the impression that the PREEMPT RT kernel "just" made the
> standard primitives more predictable & hence suitable for RT.
>
> I found http://pengutronix.de/software/linux-rt/debian_en.html and was
> going to have a go, but it looks as though they only support sid and I
> don't plan to update just yet!

There seems to be some real-time-ness in the standard Debian squeeze
kernel (2.6.32???).

This is a demo program - I made the delay 12 ms in case the OS tick was
10 ms; it isn't.

with Ada.Calendar;
with Ada.Text_Io; use Ada.Text_Io;
with Ada.Integer_Text_Io; use Ada.Integer_Text_Io;

procedure Check_Real_Time is
   --  Accumulates a histogram of the actual time taken by a notional
   --  12-ms delay. The bucket size is 0.01 ms.
   --
   --  Only prints out the non-zero buckets.
   subtype Bucket_Index is Natural range 0 .. 40000;
   Buckets : array (Bucket_Index) of Natural := (others => 0);
   use type Ada.Calendar.Time;
   Next : Ada.Calendar.Time;
begin
   Next := Ada.Calendar.Clock;
   for J in 1 .. 1000 loop
      declare
	 Start : constant Ada.Calendar.Time := Ada.Calendar.Clock;
	 Actual_Interval : Natural;  -- in hundredth-milliseconds
      begin
	 Next := Next + 0.012;
	 delay until Next;
	 Actual_Interval := Natural ((Ada.Calendar.Clock - Start) * 100_000.0);
	 if Actual_Interval > Buckets'Last then
	    Buckets (Buckets'Last) := Buckets (Buckets'Last) + 1;
	 else
	    Buckets (Actual_Interval) := Buckets (Actual_Interval) + 1;
	 end if;
      end;
   end loop;
   for J in Buckets'Range loop
      if Buckets (J) > 0 then
	 Put (J, Width => 5);
	 Put (Buckets (J), Width => 5);
	 New_Line;
      end if;
   end loop;
end Check_Real_Time;

Running the program wthout any special treatment:

   root@flambard:/home/simon# ./check_real_time 
    1120    1
    1136    1
    1163    1
    1165    1
    1176    1
    1189    1
    1191    2
    1197    1
    1198   32
    1199   36
    1200  852
    1201   24
    1202   36
    1203    1
    1204    1
    1208    1
    1209    1
    1210    1
    1211    1
    1225    1
    1235    1
    1238    1
    1264    1
    1280    1

Running the program at elevated but non-real-time priority:

   root@flambard:/home/simon# nice -1 ./check_real_time 
    1098    1
    1099    1
    1125    1
    1136    1
    1148    1
    1153    1
    1165    1
    1182    1
    1183    1
    1184    1
    1186    1
    1191    1
    1193    1
    1195    2
    1197    3
    1198   37
    1199   18
    1200  860
    1201   14
    1202   34
    1203    1
    1204    1
    1205    2
    1208    1
    1209    2
    1215    1
    1217    2
    1218    1
    1231    1
    1236    1
    1247    1
    1253    1
    1263    1
    1272    1
    1275    1
    1302    1

Running the program with elevated real-time priority:

   root@flambard:/home/simon# chrt 1 ./check_real_time 
    1194    1
    1195    1
    1198   37
    1199   26
    1200  872
    1201   22
    1202   35
    1203    4
    1206    1
    1208    1

Not perfect, but much better! (by the way, there was no other
user-generated load).



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Ada and linux real time
  2012-03-17 15:50                   ` Simon Wright
@ 2012-03-18 22:03                     ` slos
  2012-03-19 11:29                       ` Georg Bauhaus
  0 siblings, 1 reply; 23+ messages in thread
From: slos @ 2012-03-18 22:03 UTC (permalink / raw)


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)




^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Ada and linux real time
  2012-03-18 22:03                     ` slos
@ 2012-03-19 11:29                       ` Georg Bauhaus
  2012-03-19 13:01                         ` Simon Wright
  0 siblings, 1 reply; 23+ messages in thread
From: Georg Bauhaus @ 2012-03-19 11:29 UTC (permalink / raw)


On 18.03.12 23:03, slos wrote:

>          delay until Next_Time;
> 
>          MyDuration := To_Duration (Clock - Next_Time);

I haven't looked very closely, but if, say, Next_Time has
a value of 12 o'clock, then

   delay until Next_Time;

   -- (it is now 12 o'clock)

   My_Duration := Clock - Next_Time;

will likely measure 12 o'clock - 12 o'clock, unless performing
"-" takes time, or (parts of) the assignment statement is (are)
put on hold by the scheduler, interrupting the task.
I think that's unlike Simon's program, which subtracts
a starting time, not next_time, from the current time.


Minor comment on Threshold:  If you assign

   Thresholds :=
     (1 => MyPeriodDuration *  0.001,
      2 => MyPeriodDuration *  0.005,
      ...);

then the compiler will check that every slot gets a value.
If you run the compiler with switch -gnatwa (when using GNAT),
it will give a few more useful warnings.



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Ada and linux real time
  2012-03-19 11:29                       ` Georg Bauhaus
@ 2012-03-19 13:01                         ` Simon Wright
  2012-03-19 13:12                           ` slos
  2012-03-19 13:20                           ` Dmitry A. Kazakov
  0 siblings, 2 replies; 23+ messages in thread
From: Simon Wright @ 2012-03-19 13:01 UTC (permalink / raw)


Georg Bauhaus <rm.dash-bauhaus@futureapps.de> writes:

> On 18.03.12 23:03, slos wrote:
>
>>          delay until Next_Time;
>> 
>>          MyDuration := To_Duration (Clock - Next_Time);
>
> I haven't looked very closely, but if, say, Next_Time has a value of
> 12 o'clock, then
>
>    delay until Next_Time;
>
>    -- (it is now 12 o'clock)
>
>    My_Duration := Clock - Next_Time;
>
> will likely measure 12 o'clock - 12 o'clock, unless performing "-"
> takes time, or (parts of) the assignment statement is (are) put on
> hold by the scheduler, interrupting the task.  I think that's unlike
> Simon's program, which subtracts a starting time, not next_time, from
> the current time.

I think the point of slos's code is that the delay is supposed to finish
at Next_Time, but may (if the OS isn't very 'RT') finish later; the code
measures this.

I tried this on the same machine as my last report, but got the same
result using 'chrt 1 ./rt_test' as plain './rt_test' (running
   grep -r 'an unlikely phrase' .
 in another window).



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Ada and linux real time
  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 13:20                           ` Dmitry A. Kazakov
  1 sibling, 2 replies; 23+ messages in thread
From: slos @ 2012-03-19 13:12 UTC (permalink / raw)


Yes ! That's it Mister Wright !
I am trying to see how is the jitter on the periodic task.

And how it compares with a RT kernel.

It is rather normal that it behaves well on a normal kernel with 4 CPU
and no load.
I will try stressing the system with the tools from OSADL. I can't
right now.

Mister Bauhaus, you comment on the array initialization is well
received.
I had noticed Mister Wright one :
   Buckets : array (Bucket_Index) of Natural := (others => 0);

Thank you for your comments.
BR
Stéphane



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Ada and linux real time
  2012-03-19 13:01                         ` Simon Wright
  2012-03-19 13:12                           ` slos
@ 2012-03-19 13:20                           ` Dmitry A. Kazakov
  1 sibling, 0 replies; 23+ messages in thread
From: Dmitry A. Kazakov @ 2012-03-19 13:20 UTC (permalink / raw)


On Mon, 19 Mar 2012 13:01:22 +0000, Simon Wright wrote:

> I think the point of slos's code is that the delay is supposed to finish
> at Next_Time, but may (if the OS isn't very 'RT') finish later; the code
> measures this.

Though being RT does not imply anything about the precision of such
waiting. Jitter is probably more important, though not essential either.

P.S. 1�s clock resolution looks satisfactory, but rather disappointing. I
expected better from Debian. Can anybody comment on how to fix that?

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Ada and linux real time
  2012-03-19 13:12                           ` slos
@ 2012-03-19 13:30                             ` slos
  2012-03-19 13:35                             ` Dmitry A. Kazakov
  1 sibling, 0 replies; 23+ messages in thread
From: slos @ 2012-03-19 13:30 UTC (permalink / raw)


And what about Xenomai ?

Does anyone use Xenomai with Ada ?

I have seen some stuff in GNAT but still have no idea on how to
proceed.

I have to investigate on how to get an Ada runtime specific to this
platform.
If somebody knows...

BR
Stéphane



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Ada and linux real time
  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
  1 sibling, 1 reply; 23+ messages in thread
From: Dmitry A. Kazakov @ 2012-03-19 13:35 UTC (permalink / raw)


On Mon, 19 Mar 2012 06:12:47 -0700 (PDT), slos wrote:

> I am trying to see how is the jitter on the periodic task.

You need a better clock to measure jitter. But why is it so important to
you? I mean if you need something really hard, then your task is very
unlikely to be triggered by the timer. It would be some external source
instead.

See ARM C.3.2. With an interrupt handler you can latencies well under 1�s.

(What are you programming, a Jedi lightsaber? (:-))

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Ada and linux real time
  2012-03-19 13:35                             ` Dmitry A. Kazakov
@ 2012-03-19 16:11                               ` slos
  2012-03-19 17:55                                 ` Dmitry A. Kazakov
  0 siblings, 1 reply; 23+ messages in thread
From: slos @ 2012-03-19 16:11 UTC (permalink / raw)


As I am learning Ada after some procrastination, I thought I could
implement a simple PLC like control framework that could run on a RT
Linux context, allowing very simple to quite complex control
applications.

The user would benefit the overall structure and components from the
framework and program his application logic in some Ada procedures.
Even if only knowing IEC 61131-3 languages, a PLC programmer could
learn by doing since Ada basics are quite easy to learn.
One can compare with Structured Text, one of the languages defined in
IEC 61131-3.

Although Ada looks to me appealing for control application
development, I think no one will give a try to this framework if it is
not available to anybody and GPLed on one hand and performing well on
the other.

What do you think about my light sabre ? ;-)

BR
Stéphane



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Ada and linux real time
  2012-03-19 16:11                               ` slos
@ 2012-03-19 17:55                                 ` Dmitry A. Kazakov
  2012-03-19 22:20                                   ` slos
  0 siblings, 1 reply; 23+ messages in thread
From: Dmitry A. Kazakov @ 2012-03-19 17:55 UTC (permalink / raw)


On Mon, 19 Mar 2012 09:11:16 -0700 (PDT), slos wrote:

> As I am learning Ada after some procrastination, I thought I could
> implement a simple PLC like control framework that could run on a RT
> Linux context, allowing very simple to quite complex control
> applications.
> 
> The user would benefit the overall structure and components from the
> framework and program his application logic in some Ada procedures.
> Even if only knowing IEC 61131-3 languages, a PLC programmer could
> learn by doing since Ada basics are quite easy to learn.
> One can compare with Structured Text, one of the languages defined in
> IEC 61131-3.
> 
> Although Ada looks to me appealing for control application
> development, I think no one will give a try to this framework if it is
> not available to anybody and GPLed on one hand and performing well on
> the other.

Distributed control applications is what we are using Ada for.

> What do you think about my light sabre ? ;-)

You don't need an RT OS for most PLCs. Even Windows is real time enough to
deliver 5ms cycles.

Of course, it depends on the physical process. The things we control are
very fast (burning processes). This is why our cycles are quite short
0.2-0.1ms. But that is rather an exception. For mechanical systems 1ms
should be enough. And more mass you have to move, longer can be the cycle
and less should you worry about the jitter.

So, if the sabre is not of light, you could just use Windows or normal
Linux.

The superiority of Ada is that what you write is truly portable. Our
engineers test their models right under Windows and only when these work
they actually try VxWorks. The code is exactly same, no modifications
needed. The sensors/actuators and networking communication is decoupled by
a middleware, which is also written in Ada.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Ada and linux real time
  2012-03-19 17:55                                 ` Dmitry A. Kazakov
@ 2012-03-19 22:20                                   ` slos
  2012-03-20  8:04                                     ` Dmitry A. Kazakov
  0 siblings, 1 reply; 23+ messages in thread
From: slos @ 2012-03-19 22:20 UTC (permalink / raw)


Hello Mister Kazakov,

> You don't need an RT OS for most PLCs. Even Windows is real time enough to
> deliver 5ms cycles.
I agree.
>
> Of course, it depends on the physical process. The things we control are
> very fast (burning processes). This is why our cycles are quite short
> 0.2-0.1ms. But that is rather an exception. For mechanical systems 1ms
> should be enough. And more mass you have to move, longer can be the cycle
> and less should you worry about the jitter.
I agree. This is why I wonder about PREEMPT_RT.
>
> So, if the sabre is not of light, you could just use Windows or normal
> Linux.
Right.
>
> The superiority of Ada is that what you write is truly portable.
Well, I am here for that reason among others.
> Our engineers test their models right under Windows and only when these work
> they actually try VxWorks. The code is exactly same, no modifications
> needed. The sensors/actuators and networking communication is decoupled by
> a middleware, which is also written in Ada.
You could say the same about RTX. I am not a specialist of those
systems.
But I am looking for a free alternative.
>
> --
> Regards,
> Dmitry A. Kazakovhttp://www.dmitry-kazakov.de

I know I can have this framework working on Linux. It actually does so
and pretty well so far.
I am experimenting with Ada and Real Time on Linux and there are at
least three alternatives : PREEMPT_RT for general control, Xenomai and
RTAI for higher performance needs.

For the moment I don't know how this framework will evolve since :
- I am learning Ada and I don't know if I will find it interesting
enough to continue,
- I am targeting simple process control for beginners but I want to be
sure it can scale to motion control applications as well, and in this
case I want to know the feasibility and experiment with it,
- I have not that much time and life is short.

Anyway, I've found the GNAT doc and the sources.
http://gcc.gnu.org/onlinedocs/gnat_ugn_unw/index.html#Top

And interesting chapter:
http://gcc.gnu.org/onlinedocs/gnat_ugn_unw/Specifying-a-Run_002dTime-Library.html#Specifying-a-Run_002dTime-Library

The sources seem to contain already some Xenomai stuff like :
- s-osinte-linux-xenomai.ads
--  This is a GNU/Linux (Xenomai) version of this package

--  This package encapsulates all direct interfaces to OS services
--  that are needed by the tasking run-time (libgnarl).
package System.OS_Interface is...

- s-osprim-linux-xenomai.adb
package body System.OS_Primitives is...

- s-taprop-linux-xenomai.adb
package body System.Task_Primitives.Operations is...

- s-taspri-linux-xenomai.ads
package System.Task_Primitives is...

But it seems not finished and I find no instructions or indications in
the makefiles. :-(

BR
Stéphane



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Ada and linux real time
  2012-03-19 22:20                                   ` slos
@ 2012-03-20  8:04                                     ` Dmitry A. Kazakov
  0 siblings, 0 replies; 23+ messages in thread
From: Dmitry A. Kazakov @ 2012-03-20  8:04 UTC (permalink / raw)


On Mon, 19 Mar 2012 15:20:20 -0700 (PDT), slos wrote:

> But I am looking for a free alternative.

It would be rather difficult to find. Hardware protocols are very, if not
to say extremely, complex. The documentation is not free in most cases. So
free implementations are either non existent or do not go beyond simple
exercises.

> I am experimenting with Ada and Real Time on Linux and there are at
> least three alternatives : PREEMPT_RT for general control, Xenomai and
> RTAI for higher performance needs.

The only reason to have it preemptive is because of hardware communication
requiring asynchronous handling, e.g. a network stack. Unless you have
something very, very complex running in multiple cycles...

On the other hand something complex like that is quite difficult to ensure
meeting time constraints without doing a lot of additional work. So, if I
were you, I would not care. Just do your PLC and see if it works.

> - I am targeting simple process control for beginners but I want to be
> sure it can scale to motion control applications as well, and in this
> case I want to know the feasibility and experiment with it,

We did some scalability tests for our Ada software. In short, you should
not worry. If it does not scale, then not because of Ada.

> --  This package encapsulates all direct interfaces to OS services
> --  that are needed by the tasking run-time (libgnarl).

I don't think a PLC would need anything like that; maybe, but rather
unlikely.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2012-03-20  8:05 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox