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,7001494ace46eea7 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-09-19 11:22:16 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: adam@irvine.com (Adam Beneschan) Newsgroups: comp.lang.ada Subject: Re: Overriding discriminants perplexes GNAT 3.14p Date: 19 Sep 2002 11:22:15 -0700 Organization: http://groups.google.com/ Message-ID: References: NNTP-Posting-Host: 66.126.103.122 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1032459736 26832 127.0.0.1 (19 Sep 2002 18:22:16 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 19 Sep 2002 18:22:16 GMT Xref: archiver1.google.com comp.lang.ada:29189 Date: 2002-09-19T18:22:16+00:00 List-Id: Dmitry A.Kazakov wrote in message news:... > 2. Circular requeue hangs at run-time under Linux: > > package Objects is > protected Object1 is > entry Point1; > entry Point2; > end Object1; > protected Object2 is > entry Point1; > end Object2; > end Objects; > ------------ > package body Objects is > protected body Object1 is > entry Point1 when True is > begin > requeue Object2.Point1; > end Point1; > entry Point2 when True is > begin > null; > end Point2; > end Object1; > protected body Object2 is > entry Point1 when True is > begin > requeue Object1.Point2; > end Point1; > end Object2; > end Objects; > ------------ > with Ada.Text_IO; use Ada.Text_IO; > with Objects; > > procedure Test is > begin > Objects.Object1.Point1; > Put_Line ("That's OK"); > end Test; I think GNAT's behavior is legitimate here. Protected entry calls and external requeues start new "protected actions" on the target protected object (9.5.3(8), 9.5.4(11)). Thus, when Objects.Object1.Point1 is called, a new protected action is started on Object1. When this requeues to Object2.Point1, a new protected action is started on Object2; however, the protected action on Object1 does not complete (AI95-00148). When Object2.Point1 then requeues to Object1.Point2, it attempts to start a new protected action on Object1. However, 9.5.1(4) says that a new protected action cannot be "started on a protected object while another protected action on the same protected object is underway". Thus, the requeue to Object1.Point2 must wait until the already in-progress protected action is completed, and that can never happen; the result is deadlock. Note that the second requeue is not necessarily "queued"---see 9.5.1(18). See also 9.5.1(8-16), which says that if a protected action performs an external requeue on the same target object as that of a protected action (which is what your program does, indirectly), it is a bounded error. Implementations may or may not detect this error; see 9.5.1(17). In other words, it's your program that's in error here, not GNAT. -- Adam