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-Thread: a07f3367d7,25642dc8f94534f6 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!32g2000prq.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Basic question about select Date: Wed, 28 Apr 2010 19:16:54 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <1p2m3s7y70lsa$.79fl3we9edva$.dlg@40tude.net> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1272507414 16125 127.0.0.1 (29 Apr 2010 02:16:54 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 29 Apr 2010 02:16:54 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: 32g2000prq.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:11247 Date: 2010-04-28T19:16:54-07:00 List-Id: On Apr 28, 5:20=A0pm, "Jeffrey R. Carter" wrote: > Dmitry A. Kazakov wrote: > > > =A0 =A0protected Event is > > =A0 =A0 =A0 procedure Signal; > > =A0 =A0 =A0 entry Wait; > > =A0 =A0private > > =A0 =A0 =A0 Signaled : Boolean :=3D False; > > =A0 =A0end Event; > > > =A0 =A0protected body Event is > > =A0 =A0 =A0 procedure Signal is > > =A0 =A0 =A0 begin > > =A0 =A0 =A0 =A0 =A0Signaled :=3D True; > > =A0 =A0 =A0 end Signal; > > =A0 =A0 =A0 entry Wait when Signaled is > > =A0 =A0 =A0 begin > > =A0 =A0 =A0 =A0 =A0Signaled :=3D False; > > =A0 =A0 =A0 end; > > =A0 =A0end Event; > > > =A0 =A0task PID is > > =A0 =A0 =A0 entry Call; > > =A0 =A0end PID; > > > =A0 =A0task body PID is > > =A0 =A0begin > > =A0 =A0 =A0 accept Call do Event.Wait; end; > > =A0 =A0end PID; > > > begin > > =A0 select > > =A0 =A0 =A0PID.Call; =A0-- Blocked in the rendezvous > > =A0 then abort > > =A0 =A0 =A0delay 2.0; > > =A0 =A0 =A0Event.Signal; -- Releases the rendezvous after 2s > > =A0 end select; > > > If abort to happen after *completion* of the rendezvous then the above > > shall not deadlock. (I checked this under GNAT/Windows, it deadlocks > > there.) > > Here the call to PID.Call is not queued, but is accepted immediately, and= does > not encounter an explicit requeue-with-abort. Is that necessarily the case? Since there aren't any priorities specified, I don't think it's defined whether the body of the main procedure (assuming it's a procedure) starts running first, or the body of PID (assuming a single processor). Which means that the entry call could be queued. Actually, on second thought, I think that for some dispatching policies the main procedure *will* be executed first, which means that the SELECT is executed before the body of PID starts, which means the call *is* queued. Of course, it will be accepted "almost" immediately; but since the call is briefly queued, the language of 9.7.4 means that the abortable part is started. Then, during "delay 2.0", PID is started, the call is accepted, but it doesn't complete. Then the delay finishes and the Signal occurs; an attempt is made to cancel the entry call PID.Call, but that has no effect since cancellation only works when the call is on a queue (9.5.3(20)). Anyway, as soon as the Signal occurs, the Wait completes, then the entry call to PID.Call completes, and then everything is done. At least that's how I understand things, but I could be wrong. In any event, though, writing code like this has to be horrible since you can't tell whether it will deadlock or not. -- Adam