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.191.2 with SMTP id gu2mr13351201pbc.0.1323800064676; Tue, 13 Dec 2011 10:14:24 -0800 (PST) Path: lh20ni18573pbb.0!nntp.google.com!news1.google.com!goblin1!goblin.stu.neva.ru!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:14:23 +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> 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="U2FsdGVkX18nrrPq4I7SQnLDzkxQG/djsHyFgNeBNe8=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (darwin) Cancel-Lock: sha1:92MsQz2FfSzoCSVPnoZGA5qh8QM= sha1:dGP5DKu7uMb7RuicVdSfFngTSoE= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Date: 2011-12-13T18:14:23+00:00 List-Id: Ada BRL writes: > On 13 Dic, 15:07, Simon Wright wrote: >> 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 > > I haven't understood you... > What does it mean "declaring a protected task"? You would not > recommend it, ok, but what does it mean? > In the example above is the Buffer (member of main) the unique > protected object or the main function itself has to be declared as > protected? > > Sorry but I'm beginning to loose the thread... Not surprised, it seems to me we're giving you answers well above your current level of knowledge of Ada. Sorry about that. [1] is a better explanation of tasking & protected types than I can provide quickly (maybe at all!) [2] contains two implementations; queueing_po* are the files for a protected object implementation, queueing_task* for a task implementation. You will see that the structures of the two main programs (queueing_po_main, queueing_task_main) are identical. One of the reasons I wouldn't use a task here is that you have to manage the active thread of the task. An example of the sort of thing I mean is that when you run queueing_po_main it stops after 20 ines of output, but when you run queueing_task_main it hangs at that point and you have to stop it from the outside (by Crtl-C, for example). The reason is that the task Queue has no reason to stop and just waits forever (in this simple case you could probably fix that fairly simply, but in general it's not easy at all; best to avoid the problem). [1] http://en.wikibooks.org/wiki/Ada_Programming/Tasking (sections 1, 2) [2] http://dl.dropbox.com/u/34783908/Ada/queueing.zip