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, REPLYTO_WITHOUT_TO_CC autolearn=no 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-02 00:26:14 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!news-FFM2.ecrc.net!fu-berlin.de!uni-berlin.de!dialin-145-254-036-157.arcor-ip.NET!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Suspicious reentrant semaphore Date: Fri, 02 May 2003 09:28:09 +0200 Organization: At home Message-ID: References: Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: dialin-145-254-036-157.arcor-ip.net (145.254.36.157) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: fu-berlin.de 1051860373 13777426 145.254.36.157 (16 [77047]) User-Agent: KNode/0.7.1 Xref: archiver1.google.com comp.lang.ada:36837 Date: 2003-05-02T09:28:09+02:00 List-Id: 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