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=unavailable autolearn_force=no version=3.4.4 Path: border2.nntp.dca1.giganews.com!nntp.giganews.com!newspeer1.nac.net!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!news.tele.dk!news.tele.dk!small.news.tele.dk!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: can someone help me with this code (explanation) Date: Thu, 25 Sep 2014 23:10:34 +0300 Organization: Tidorum Ltd Message-ID: References: <6e1f86e6-c17a-428e-bb19-460c5ba26c8a@googlegroups.com> <1ec7272d-de7f-43dd-be30-009c437011de@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: individual.net EhjLsFsWOKe/Q7WhjLrEDwo08OIexfloi/ku2JD1d2WJ3pvjAk Cancel-Lock: sha1:8jvCLSUOf13HVpQ2Iv1H0NkFyNQ= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: <1ec7272d-de7f-43dd-be30-009c437011de@googlegroups.com> Xref: number.nntp.dca.giganews.com comp.lang.ada:189158 Date: 2014-09-25T23:10:34+03:00 List-Id: On 14-09-25 22:41 , Stribor40 wrote: > is.... I am ready to make a hot dog for you > > first line of the output text always regardless how many cpu? It is guaranteed that the first call of Ada.Text_IO.Put_Line will be that call, because Bill and John call Put_Line only after getting their hot-dogs from Gourmet, after calling and returning from Make_A_Hot_Dog. The rendez-vous at the accept statement in Gourmet synchronises the order of execution of the statements in the tasks (well, in the calling task and the accepting task; as has already been said, the execution progress of other tasks, at that time, cannot be predicted in general). Each task executes its statements sequentially, but the relative order of execution in different tasks is known only at such synchronisation points. It is not guaranteed, as I understand it, that the text string "I am ready to make a hot dog for you" will appear intact on your screen, because Ada.Text_IO is not meant to be used concurrently from several tasks, on the same file (here, Standard_Output). In practice, it probably will appear on your screen. To make task-safe use of Ada.Text_IO, it should be wrapped in some way to ensure that only one task calls it at a time. For example, you could write a task with an entry like Put_Line (Message : in String) and an accept statement that does Ada.Text_IO.Put_Line (Message). But a protected-object wrapper is probably better for uses where I/O performance (latency) is not critical. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .