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=-0.3 required=5.0 tests=BAYES_00,FORGED_YAHOO_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,23ffa52608fbb144,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.191.225 with SMTP id hb1mr16389769pbc.5.1337394640380; Fri, 18 May 2012 19:30:40 -0700 (PDT) Path: pr3ni3366pbb.0!nntp.google.com!news2.google.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post02.iad.highwinds-media.com!KNOLOGY.NET-a2kHrUvQQWlmc!not-for-mail From: Tim McGuire Newsgroups: comp.lang.ada Subject: Problem with Delay Alternative in Finalization Date: Fri, 18 May 2012 21:30:31 -0500 Message-ID: <6v0er7d545kvs3pr7aqe1dnrlq4mg5ldhg@4ax.com> X-Newsreader: Forte Agent 6.00/32.1186 trialware MIME-Version: 1.0 X-Complaints-To: abuse@usenetserver.com Organization: UseNetServer.com X-Trace: 7b1204fb705d1bd8f493d19614 X-Received-Bytes: 3397 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: 2012-05-18T21:30:31-05:00 List-Id: I am porting code from Solaris to Linux. I am running in to a problem where a delay alternive used when in finalization doesn't seem to be working properly. The delay part never seems to happen. The actual code is very complex, so I wrote a simple test to see if the problem still existed. I know there are better ways to do what this test program does, but I am just trying to see if I can reproduce the problem from the actual code. I am using GCC 4.3.4 and to compile the program I issue the following commands: gnatname "*.[12].ada" gnatmake token_test.2.ada -o token_test.exe (spec) =========== with Ada.Finalization; package Test_Lock_Token is Lock_Timeout_Exception : exception; Unknown_Exception : exception; type Lock_Token is Ada.Finalization.Limited_Controlled with null record; private procedure Initialize (Object : in out Lock_Token); procedure Finalize (Object : in out Lock_Token); end Test_Lock_Token; =========== (body) =========== package body Test_Lock_Token is protected Lock_Type is entry Acquire; procedure Release; private Blocked : Boolean := False; end Lock_Type; protected body Lock_Type is entry Acquire when (not Blocked) is begin Blocked := True; end Acquire; procedure Release is begin if Blocked then Blocked := False; else raise Unknown_Exception; end Release; end Lock_Type; procedure Initialize (Object : in out Lock_Token) is begin select Lock_Type.Acquire or delay 2.0; raise Lock_Timeout_Exception; end select; end Initialize; procedure Finalize (Object : in out Lock_Token) is begin Lock_Type.Release; end Finalize; end Test_Lock_Token; =========== With a main of =========== with Ada.Text_Io; with Test_Lock_Token; Procedure Token_Test is begin declare Token : Test_Lock_Token.Lock_Token; begin Ada.Text_Io.Put_Line ("Got Token"); declare Token_2 : Test_Lock_Token.Lock_Token; begin Ada.Text_Io.Put_Line ("Got Token_2"); exception When Errors : Test_Lock_Token.Lock_Timeout_Exception => Ada.Text_Io.Put_Line ("Token_2 timed out!"); end; exception When Errors : Test_Lock_Token.Lock_Timeout_Exception => Ada.Text_Io.Put_Line("Token timed out!"); end; end Token_Test =========== will lock up on the second attempt to get the token. Why doesn't the delay happen and raise the timeout exception? It's not practical to rewrite the code unless absolutely neccessary. Is there some compiler directive or pragma that I need to use in order to get the delay alternative to work properly? Thanks, Tim