From: "David C. Hoos" <david.c.hoos.sr@ada95.com>
Subject: Re: Problems with Ada.Real_Time on GNAT?
Date: Thu, 16 May 2002 15:53:56 -0500
Date: 2002-05-16T15:53:56-05:00 [thread overview]
Message-ID: <mailman.1021582442.8726.comp.lang.ada@ada.eu.org> (raw)
In-Reply-To: 87k7q3c0di.fsf@deneb.enyo.de
----- Original Message -----
From: "Florian Weimer" <fw@deneb.enyo.de>
Newsgroups: comp.lang.ada
To: <comp.lang.ada@ada.eu.org>
Sent: Thursday, May 16, 2002 3:18 PM
Subject: Re: Problems with Ada.Real_Time on GNAT?
> file13@qlippoth.zzn.com (file13) writes:
>
> > http://www.qlippoth.com/shuffle.adb
> >
> > It works fine under Windows 2000 but on Linux under both 3.13 and 3.14
> > I (and the guy who is testing all the programs) keep getting
> > segmentation faults when run.
>
> You are hitting the 2 MB stack size limit. You should allocate the
> large array using an allocator.
With all due respect, I submit that the problem is _not_ the stack limit,
but, rather the fact that to use the real-time annex, one must compile and
link
with the FSU threads run-time, instead of the Linux-native threads run-time.
One disadvantage of running under the FSU run-time, is that processes must
run with root privileges -- e.g., by means of setuid permissions and root
ownership of the executable.
Instead, I chose to use the facilities of Ada.Calendar, and I also took the
liberty
of showing a better way to define the types, and cleaning up the output by
limiting the number of values on a line to ten.
Here is the modified code -- it should run correctly under either run-time:
with Ada.Calendar;
with Ada.Numerics.Discrete_Random;
with Ada.Text_IO;
procedure Shuffle is
subtype Index is Integer range 1 .. 1000000;
-- Regular vars
List : array (Index) of Integer;
X, Tmp : Integer;
-- Timing stuff
Start : Ada.Calendar.Time;
Finish : Ada.Calendar.Time;
-- Random integer stuff
package Rand is new Ada.Numerics.Discrete_Random (Index);
Seed : Rand.Generator;
use type Ada.Calendar.Time;
begin
Rand.Reset (Seed);
-- Populate List
Ada.Text_IO.Put_Line
("Populating collection list...");
for I in List'Range loop
List (I) := I;
end loop;
-- Shuffle
Ada.Text_IO.Put_Line
("Randomizing collection list. Starting timer:");
Start := Ada.Calendar.Clock;
for I in List'Range loop
X := Rand.Random (Seed);
Tmp := List (I);
List (I) := List (X);
List (X) := Tmp;
end loop;
Finish := Ada.Calendar.Clock;
Ada.Text_IO.New_Line;
Ada.Text_IO.Put_Line
("Time to shuffle in seconds:" & Duration'Image (Finish - Start));
-- Print 1st 100 of List
Ada.Text_IO.New_Line;
for I in 1 .. 100 loop
Ada.Text_IO.Put (Integer'Image (List (I)));
if I mod 10 = 0 then
Ada.Text_IO.New_Line;
end if;
end loop;
end Shuffle;
next prev parent reply other threads:[~2002-05-16 20:53 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-05-16 19:33 Problems with Ada.Real_Time on GNAT? file13
2002-05-16 20:18 ` Florian Weimer
2002-05-16 20:53 ` David C. Hoos [this message]
2002-05-17 6:57 ` Florian Weimer
2002-05-17 9:57 ` Robert Dewar
2002-05-17 18:38 ` Florian Weimer
2002-05-18 2:49 ` Robert Dewar
2002-05-17 19:49 ` file13
2002-05-17 4:36 ` Per Sandbergs
2002-05-27 2:42 ` Robert I. Eachus
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox