comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Is Text_IO.Put_Line() thread-safe?
Date: Thu, 14 Jun 2012 14:24:49 -0400
Date: 2012-06-14T14:24:49-04:00	[thread overview]
Message-ID: <wcc7gv9ycni.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: cfd4cf5d-9fd5-4288-b2b8-304626b8ca16@googlegroups.com

awdorrin <awdorrin@gmail.com> writes:

> I was afraid of that... I was hoping that there would be a way to set
> a flag to keep the task from switching in the middle of the Put_Line.

It's not just an issue of task switching.
Consider a multiprocessor machine.

> Something like:
> CriticalSection.On;
> Text_IO.Put_Line("blah blah");
> CriticalSection.Off;

It's not hard to write a protected object CriticalSection
that does something like that.  But you don't want to
scatter those calls all over -- you want a single atomic
Put_Line primitive.

> (Thinking back to Win32 C programming days...)
>
> I'm not that worried about the corruption in the Put_Line itself, what
> I'm worried about is if the corruption will go both ways, meaning
> could it corrupt the record array that is being sorted. (Like the text
> string being printed ending up in the middle of a data record.)

I'm not sure what you mean by that, but if you don't do proper
synchronization, it's erroneous, which means anything could
happen, including corruption of arbitrary data.

You might have other race conditions in your code (besides
the Put_Lines, I mean) -- something worth looking for.

- Bob



  reply	other threads:[~2012-06-14 18:24 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-14 12:53 Is Text_IO.Put_Line() thread-safe? awdorrin
2012-06-14 13:49 ` Robert A Duff
2012-06-14 14:35   ` Adam Beneschan
2012-06-14 14:38   ` Dmitry A. Kazakov
2012-06-14 14:56     ` J-P. Rosen
2012-06-14 16:01       ` Dmitry A. Kazakov
2012-06-14 18:34       ` Robert A Duff
2012-06-21 19:01         ` Randy Brukardt
2012-06-14 18:29     ` Robert A Duff
2012-06-21 19:04       ` Randy Brukardt
2012-06-14 21:14     ` tmoran
2012-06-14 14:42   ` awdorrin
2012-06-14 18:24     ` Robert A Duff [this message]
2012-06-14 20:37       ` awdorrin
2012-06-14 21:37         ` Robert A Duff
2012-06-15  5:32           ` Georg Bauhaus
2012-06-15  7:22             ` Dmitry A. Kazakov
2012-06-15 21:32               ` Robert A Duff
2012-06-16  7:41                 ` Dmitry A. Kazakov
2012-06-15 21:27             ` Robert A Duff
2012-06-14 18:56 ` Jeffrey Carter
2012-06-14 20:50   ` awdorrin
2012-06-14 21:41     ` Robert A Duff
2012-06-15 12:39       ` awdorrin
2012-06-14 22:17     ` Jeffrey Carter
2012-06-14 22:40       ` Simon Wright
2012-06-14 23:35         ` Jeffrey Carter
2012-06-15  5:04           ` Simon Wright
2012-06-15  5:41             ` Jeffrey Carter
2012-06-21 19:20             ` Randy Brukardt
2012-06-16  2:00       ` BrianG
2012-06-16  6:04         ` J-P. Rosen
2012-06-16  6:49           ` Simon Wright
2012-06-16  7:58             ` Dmitry A. Kazakov
2012-06-16  8:03               ` Simon Wright
2012-06-16  8:14                 ` Dmitry A. Kazakov
2012-06-21 19:27               ` Randy Brukardt
2012-06-16  7:51           ` Dmitry A. Kazakov
replies disabled

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