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,a6c65cbc407987fe X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-11-18 01:30:04 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.ems.psu.edu!news.litech.org!eurocyber.net!newsfeed.muc.eurocyber.net!newsfeed.stueberl.de!teaser.fr!enst.fr!not-for-mail From: "Grein, Christoph" Newsgroups: comp.lang.ada Subject: Re: dynamic multithreading Date: Mon, 18 Nov 2002 10:22:51 +0100 (MET) Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: TEXT/plain; charset=us-ascii X-Trace: avanie.enst.fr 1037611803 35482 137.194.161.2 (18 Nov 2002 09:30:03 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Mon, 18 Nov 2002 09:30:03 +0000 (UTC) Return-Path: X-Authentication-Warning: mail.eurocopter.com: uucp set sender to using -f Content-MD5: ImImwNjAeJQVPbjS7foQow== X-Mailer: dtmail 1.2.1 CDE Version 1.2.1 SunOS 5.6 sun4u sparc Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.13 Precedence: bulk X-Reply-To: "Grein, Christoph" List-Unsubscribe: , List-Id: comp.lang.ada mail<->news gateway List-Post: List-Help: List-Subscribe: , Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: archiver1.google.com comp.lang.ada:31029 Date: 2002-11-18T10:22:51+01:00 Of course this program _must_ consume all memory. You explicitly allocate on the heap, but never deallocate. That's what Unchecked_Deallocation is for. Or do you mean even with Free, it consumes all memory? > No need to argue, just try the following program with and without > the "Free". If you find one Ada95 compiler one one platform where > it does not eat up all the memory, please let us know. > > With GNAT on Solaris, VMS, Linux, HP-UX and Windows, I already know > the answer... > > -Thierry > > with Ada.Text_IO; > with Ada.Unchecked_Deallocation; > with System; > > procedure Crazy_Tasks is > > task type T is > pragma Priority (System.Priority'Last); > entry Foo; > end T; > > type Access_T is access T; > > task body T is > begin > select > accept Foo; > else > null; > end select; > end T; > > procedure Free is new Ada.Unchecked_Deallocation (T, Access_T); > > type Counter is mod 2**32; > > Count : Counter := 0; > TV : Access_T; > > begin > > loop > TV := new T; -- should terminate immediately > while not TV.all'Terminated loop > delay 0.0; > end loop; > -- Free (TV); > Count := Count + 1; > if Count mod 50_000 = 0 then > Ada.Text_IO.Put_Line (Counter'Image (Count) & " tasks"); > end if; > end loop; > > end Crazy_Tasks;