From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,10c4b1e7e98e6a93 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-05-16 13:54:04 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!fr.usenet-edu.net!usenet-edu.net!enst!enst.fr!not-for-mail From: "David C. Hoos" Newsgroups: comp.lang.ada Subject: Re: Problems with Ada.Real_Time on GNAT? Date: Thu, 16 May 2002 15:53:56 -0500 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: References: <28d8936a.0205161133.3c9064b7@posting.google.com> <87k7q3c0di.fsf@deneb.enyo.de> Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: avanie.enst.fr 1021582443 24280 137.194.161.2 (16 May 2002 20:54:03 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Thu, 16 May 2002 20:54:03 +0000 (UTC) Return-Path: X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.8 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Original-Cc: file13@qlippoth.zzn.com Xref: archiver1.google.com comp.lang.ada:24232 Date: 2002-05-16T15:53:56-05:00 ----- Original Message ----- From: "Florian Weimer" Newsgroups: comp.lang.ada To: 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;