comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: new_line in a put_line
Date: Mon, 2 Dec 2002 15:49:29 GMT
Date: 2002-12-02T15:49:29+00:00	[thread overview]
Message-ID: <wcc7kesqv3q.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: aserlb$juh$1@fang.dsto.defence.gov.au

"Vlad" <vbednikov@optusnet.com.au> writes:

> Is there a way of prepending a new_line to a put_line.
> The reason I need this is that I have multiple tasks outputing to a\
> single file. Some of them use Text_IO.Put rather then Text_IO.Put_Line.
> And because of this, some of these outputs get written on the same line
> as my outputs.

You seem to be assuming that each call to Put or Put_Line is atomic.
That's not true, so inserting a new-line into the string passed to
Put_Line is not a correct solution.

If one task says:

    Put_Line("Hello");

and another task simultaneously says:

    Put_Line("Goodbye");

the program is erroneous, which means it can have totally unpredictable
behavior.  It might intersperse the characters, so you get:

    HelGoodl
    obye

or it might print what you want:

    Hello
    Goodbye

or it might crash, or anything else.

What you need to do is synchronize your accesses to the standard output
file, perhaps using a protected object.

- Bob



  parent reply	other threads:[~2002-12-02 15:49 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-02  5:36 new_line in a put_line Vlad
2002-12-02  9:47 ` Preben Randhol
2002-12-02 17:04   ` Frank J. Lhota
2002-12-05 11:10     ` Preben Randhol
2002-12-02 10:14 ` Dmitry A. Kazakov
2002-12-02 14:57 ` Matthew Heaney
2002-12-03 11:33   ` Fraser Wilson
2002-12-03 15:01     ` Dmitry A. Kazakov
2002-12-04  9:31       ` Fraser Wilson
2002-12-04 14:10         ` Dmitry A. Kazakov
2002-12-04 15:23           ` Robert A Duff
2002-12-04 16:15             ` Dmitry A. Kazakov
2002-12-04 18:11               ` tmoran
2002-12-04 20:21                 ` Simon Wright
2002-12-05  9:36                 ` Dmitry A. Kazakov
2002-12-05 22:40                   ` tmoran
2002-12-04 15:25           ` Stephen Leake
2002-12-04 16:55             ` Jeffrey Carter
2002-12-04 17:24               ` Stephen Leake
2002-12-04 17:43               ` Warren W. Gay VE3WWG
2002-12-05  1:31                 ` Jeffrey Carter
2002-12-05 18:11                   ` Warren W. Gay VE3WWG
2002-12-02 15:49 ` Robert A Duff [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-12-03 11:52 Grein, Christoph
2002-12-04  9:39 ` Fraser Wilson
2002-12-04 10:03 Grein, Christoph
2002-12-05  6:16 Grein, Christoph
2002-12-05  9:44 ` Dmitry A. Kazakov
2002-12-05  6:28 Grein, Christoph
2002-12-05 14:19 ` Stephen Leake
replies disabled

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