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: buffer1.nntp.dca1.giganews.com!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!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Jeffrey Carter Newsgroups: comp.lang.ada Subject: Re: can someone help me with this code (explanation) Date: Thu, 25 Sep 2014 09:53:47 -0700 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Injection-Date: Thu, 25 Sep 2014 16:53:49 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="ff2e5d21b9fb0a12a9871c15f1d89f02"; logging-data="30828"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+4aZzG4+Z8dI0ZQeOltsf3tiv/HTan1zw=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.0 In-Reply-To: Cancel-Lock: sha1:aGj7Kl8fw84qvuOGZ1HlFvaxIDQ= Xref: number.nntp.dca.giganews.com comp.lang.ada:189154 Date: 2014-09-25T09:53:47-07:00 List-Id: On 09/25/2014 06:44 AM, Stribor40 wrote: > > If we assume John task starts first...first time trough the loop John does > Gourmet.Make_A_Hot_Dog(Index, TRUE); which blocks him and Goutmet starts > running so once Gourmet stops John continues does Bill calls Gourmet and John > wait in the queue in his second loop? Gourmet, Bill, and John all start at the same time. While Gourmet is printing its welcome message, Bill and John call Gourmet's entry Make_A_Hot_Dog and are blocked until Gourmet accepts the entry call. Whichever is first in the entry queue is largely a matter of chance. That is how you should think about this. If you have a computer that can run 3 or more tasks at the same time (which describes many modern computers with 2 or more cores) then it is also what happens. Even on a monoprocessor only able to run 1 task at a time what will happen will be very close to this, since Gourmet should block waiting for I/O and the eater tasks should block on the entry call, so you end up with both eaters in the queue and Gourmet reaching its accept for the 1st time. -- Jeff Carter "Blessed is just about anyone with a vested interest in the status quo." Monty Python's Life of Brian 73