comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: can someone help me with this code (explanation)
Date: Thu, 25 Sep 2014 23:10:34 +0300
Date: 2014-09-25T23:10:34+03:00	[thread overview]
Message-ID: <c8jb5lFns5kU1@mid.individual.net> (raw)
In-Reply-To: <1ec7272d-de7f-43dd-be30-009c437011de@googlegroups.com>

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
      .      @       .


  parent reply	other threads:[~2014-09-25 20:10 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
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 [this message]
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