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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 Path: buffer2.nntp.dca1.giganews.com!border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news.glorb.com!news.swapon.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: =?ISO-8859-1?Q?Bj=F6rn_Lundin?= Newsgroups: comp.lang.ada Subject: Re: can someone help me with this code (explanation) Date: Thu, 25 Sep 2014 16:56:26 +0200 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Injection-Date: Thu, 25 Sep 2014 14:55:43 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="23e59b4906029a0ce22afc4c4b1f25ee"; logging-data="8121"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/A/djccRxso5vWj4IwEE/U" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.7.0 In-Reply-To: Cancel-Lock: sha1:VWtftbNes75qzeZAqDG0OqJ+L1k= Xref: number.nntp.dca.giganews.com comp.lang.ada:189150 Date: 2014-09-25T16:56:26+02:00 List-Id: On 2014-09-25 15:44, Stribor40 wrote: > Can someone help me understand this code which is from tutorial found here... > http://infres.enst.fr/~pautet/Ada95/chap27.htm and code is here > http://infres.enst.fr/~pautet/Ada95/e_c27_p3.ada > > 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? > Bill and John starts asking Gourmet to make them a hotdog, one at a time. The order between them is not determined. Gourmet has 5 hotdogs available and Bill will ask 3 times while john asks 2 times. As soon as Gourmet has accepted Bill's or John's request, Gourmet is busy, so whoever will ask next has to wait. the order might be Bill John Bill John Bill or John Bill John Bill Bill but also (perhaps not likely) Bill Bill Bill John John Any combination is valid. (os and/or task priorities affects this) But likely the other tasks gets to line up in the select statement of Gourmet before the served task can make a new request. Once gourmet has served 5 times, it will not accept anything else, since it exits the loop. It will then terminate. Likewise for Bill and John. After they requsted their food, they will exit their loop and terminate. Once all tasks are terminated, the program itself will stop/terminate. -- Björn