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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e53617e6821a1c7e X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-05-05 04:35:16 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.uchicago.edu!yellow.newsread.com!bad-news.newsread.com!netaxs.com!newsread.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.tpinternet.pl!atlantis.news.tpi.pl!news.tpi.pl!not-for-mail From: "Michal Morawski" Newsgroups: comp.lang.ada Subject: Re: Suspicious reentrant semaphore Date: Mon, 5 May 2003 13:24:56 +0200 Organization: tp.internet - http://www.tpi.pl/ Message-ID: References: NNTP-Posting-Host: pa146.lodz.cvx.ppp.tpnet.pl X-Trace: atlantis.news.tpi.pl 1052134530 22009 213.76.60.146 (5 May 2003 11:35:30 GMT) X-Complaints-To: usenet@tpi.pl NNTP-Posting-Date: Mon, 5 May 2003 11:35:30 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Xref: archiver1.google.com comp.lang.ada:36964 Date: 2003-05-05T13:24:56+02:00 List-Id: Does it works in GNAT? I have written the following program, which cannot be compiled because the construction "then abort" is not understand by the compiler. I expect the result: **.. **.. .... .... Am I right? with Ada.Text_IO; use Ada.Text_IO; procedure Ins_Requeue is protected I is entry E1 (X, Y : Integer); entry E2 (X, Y : Integer); entry E3; private E1_X, E1_Y, E2_X, E2_Y : Integer; end I; protected body I is entry E1 (X, Y : Integer) when True is begin E1_X := X; E1_Y := Y; requeue E3 then abort; ************^^ Here is error end E1; entry E2 (X, Y : Integer) when True is begin E2_X := X; E2_Y := Y; requeue E3 then abort; end E2; entry E3 when E1_X < E2_X and E1_Y < E2_Y is begin Put ('*'); end E3; end I; begin I.E1 (3, 3); for x in 1 .. 4 loop for y in 1 .. 4 loop select I.E2 (x, y); else Put ('.'); end select; end loop; New_Line; end loop; end Ins_Requeue; -- Michal Morawski "Dmitry A. Kazakov" wrote in message news:b8t6ik$d4egi$1@ID-77047.news.dfncis.de... > Jano wrote: > > > Dmitry A. Kazakov dice... > >> The requeue statement does the trick in case you want to use a parameter > >> value in a barrier. You could add one more private entry and requeue to > >> it if the task is not the owner: > > > > Dmitry: I love this suggestion specially because is the first time I'm > > going to employ requeue (never before I faced the necessity). > > It is one of the most interesting things added to Ada 95! > > > Here is the new version of my package. I've also slightly changed the > > release logic to obtain exceptions instead of deadlocks in case of wrong > > use: > > You can also get rid of the task-id parameter, as Randy Brukardt has > suggested. Sort of: > > entry P when true is > begin > if Owner = P'Caller then > In_use := In_use + 1; > else > requeue Safe_P with abort; > end if; > end P; > > entry Safe_P when In_use = 0 is > begin > Owner := Safe_P'Caller; > In_use := 1; > end Safe_P; > > procedure V is > begin > if Owner /= Current_Task then > raise Use_error; > else > In_use:= In_use - 1; > if In_use = 0 then > Owner := Null_task_id; > end if; > end if; > end V; > > -- > Regards, > Dmitry A. Kazakov > www.dmitry-kazakov.de