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: border1.nntp.dca1.giganews.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!news-1.dfn.de!news.dfn.de!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 20:11:19 +0300 Organization: Tidorum Ltd Message-ID: References: <6e1f86e6-c17a-428e-bb19-460c5ba26c8a@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: individual.net FDYwwUrXj3uxZ6oYQDa7jAdUei89vcvXlvojdbM0Qq6+h23kT8 Cancel-Lock: sha1:6ZhEsDn3sekLI20qjj2x4klLhfI= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: <6e1f86e6-c17a-428e-bb19-460c5ba26c8a@googlegroups.com> Xref: number.nntp.dca.giganews.com comp.lang.ada:189155 Date: 2014-09-25T20:11:19+03:00 List-Id: On 14-09-25 18:54 , Stribor40 wrote: > Why would this one even be possible.... It is possible in principle, because of promises that are absent from the Ada language standard, but quite unlikely in practice, in any real Ada implementation. (However, in more complex programs, with less clear task timing, similar things can be more likely even in practice.) > Bill > Bill > Bill > John > John > > If say Bill starts first...as soon as he enters John will be in queue.... John may not yet be in the queue, for two reasons, the first one possibly true in practice: - First reason: If your computer has only one core processor, and this core can run only one task at a time (common in the past, less common now), the core may run Gourmet first, until she enters the accept statement, then run Bill until he calls Make_A_Hot_Dog, then run Gourmet again up to the delay statement, giving John no chance to execute and reach his call of Make_A_Hot_Dog. This can happen in practice. However, in practice, when Gourmet executes the delay statement the core will start running John until he calls Make_A_Hot_Dog and enters the queue. - Second reason: In principle, the Ada language standard makes no promises about task execution speed. John may take as long as he pleases to reach his first Make_A_Hot_Dog call - John can be so slow that Bill gets and eats all his hot dogs before John orders his first one. This is very unlikely in this example program, but such things can happen in practice in larger programs if there are other tasks with a priority higher than John's priority, but lower than the priorities of Bill and Gourmet. By the way, using Ada.Text_IO from multiple tasks without synchronisation, on the same file (Standard_Output), is not to be recommended -- such use of Ada.Text_IO is not "task safe", I believe. However, Put_Line and similar simple things usually work with GNAT Text_IO from multiple tasks. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .