comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: Ada and linux real time
Date: Sat, 17 Mar 2012 15:50:11 +0000
Date: 2012-03-17T15:50:11+00:00	[thread overview]
Message-ID: <m24ntnz0p8.fsf@pushface.org> (raw)
In-Reply-To: m28vizz9rx.fsf@pushface.org

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).



  reply	other threads:[~2012-03-17 15:51 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 [this message]
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
replies disabled

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