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: 103376,bdf72b2364b0da13 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,UTF8 Received: by 10.68.212.232 with SMTP id nn8mr13372128pbc.1.1323800671006; Tue, 13 Dec 2011 10:24:31 -0800 (PST) Path: lh20ni18599pbb.0!nntp.google.com!news1.google.com!goblin2!goblin.stu.neva.ru!aioe.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Interrupts handling in ADA Date: Tue, 13 Dec 2011 18:24:30 +0000 Organization: A noiseless patient Spider Message-ID: References: <30143086.6.1323549838421.JavaMail.geo-discussion-forums@vbbfq24> <6df577eb-9c6a-4f82-95e4-817f6ad1ba6e@r6g2000yqr.googlegroups.com> <515d5501-c89b-4a9d-82b6-ec3539a0c2cf@r6g2000yqr.googlegroups.com> Mime-Version: 1.0 Injection-Info: mx04.eternal-september.org; posting-host="dFCm8HWntFqmDIilBLqEJQ"; logging-data="21848"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19x4WqdbbxvIA2RSCiePoNYTuz8vYtOS1g=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (darwin) Cancel-Lock: sha1:ewaJvr1BhhxiFZvzaSqHjKw4h6s= sha1:FZWkzVfPQkDX9205nVtFVCanq24= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Date: 2011-12-13T18:24:30+00:00 List-Id: Ada BRL writes: > On 13 Dic, 15:34, Simon Wright wrote: >> Simon Wright writes: >> > Also, this isn't called an accept statement; it's an entry call. The way >> > a task indicates it's prepared to accept an entry call is by an accept >> > statement; protected objects are different. So if instead of Queue being >> > protected it was a task (not something I'd recommend) the corresponding >> > body part would have looked like >> >> >    accept Get (M : out Message) when not Buffer.Is_Empty do >> >> :blush: I can't believe I said that! >> >> The relevant section of the ARM is 9.7.1, Selective Accept, and it'd >> have looked like >> >>    select >>       when not Buffer.Is_Empty => >>          accept Get (M : out Message) do >>             M := ... >>          end Get; >>       or >>          accept Put ... > > Does this means that if the Buffer is empty I will accept the Put > instead of Get? So the "or" refers to the condition before "=>" When the compiled code gets to 'select' it looks at the 'open select alternatives'. If the Buffer is empty, that would be just Put; if not, they would be Get and Put. It then (under the hood!) checks to see if any task is waiting on any of the open select alternatives; if there are any, it chooses one and executes the accept statement; if there are none, it sets up a conditional event of some sort involving any of the open select alternatives and waits. Note that nothing will happen if Buffer.Is_Empty changes during this wait; the select alternatives are only evaluated at the 'select'. http://en.wikibooks.org/wiki/Ada_Programming/Tasking#Selective_Wait http://en.wikibooks.org/wiki/Ada_Programming/Tasking#Guards