comp.lang.ada
 help / color / mirror / Atom feed
From: "Björn Lundin" <b.f.lundin@gmail.com>
Subject: Re: can someone help me with this code (explanation)
Date: Thu, 25 Sep 2014 16:56:26 +0200
Date: 2014-09-25T16:56:26+02:00	[thread overview]
Message-ID: <m01adf$7tp$1@dont-email.me> (raw)
In-Reply-To: <a352821d-bdcc-4598-8843-3262382cadb9@googlegroups.com>

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


  reply	other threads:[~2014-09-25 14:56 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-25 13:44 can someone help me with this code (explanation) Stribor40
2014-09-25 14:56 ` Björn Lundin [this message]
2014-09-25 15:01   ` Björn Lundin
2014-09-25 15:54   ` Stribor40
2014-09-25 17:11     ` Niklas Holsti
2014-09-25 19:41       ` Stribor40
2014-09-25 19:53         ` Jeffrey Carter
2014-09-25 20:10         ` Niklas Holsti
2014-09-25 22:27           ` Jeffrey Carter
2014-09-26  7:04             ` Björn Lundin
2014-09-26  7:58               ` J-P. Rosen
2014-09-26 10:24                 ` G.B.
2014-09-26 11:48                 ` Björn Lundin
2014-09-26 12:49                   ` J-P. Rosen
2014-09-26 14:15                     ` Björn Lundin
2014-09-26 14:49                       ` J-P. Rosen
2014-09-26 15:31                         ` Björn Lundin
2014-09-26 16:08                           ` G.B.
2014-09-30  4:22                             ` Brad Moore
2014-09-30 21:59                               ` Georg Bauhaus
2014-10-01 15:38                                 ` Brad Moore
2014-09-26 16:23                           ` Dmitry A. Kazakov
2014-09-26 20:38                           ` J-P. Rosen
2014-09-27 18:16                             ` Björn Lundin
2014-09-26 16:43                       ` Niklas Holsti
2014-09-26 16:45                 ` Niklas Holsti
2014-10-09  2:45                   ` Randy Brukardt
2014-09-26 16:44             ` Niklas Holsti
2014-09-26  5:06           ` J-P. Rosen
2014-09-25 16:53 ` Jeffrey Carter
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox