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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,534dd301375921ac X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.191.225 with SMTP id hb1mr3192732pbc.5.1339698290651; Thu, 14 Jun 2012 11:24:50 -0700 (PDT) Path: l9ni50738pbj.0!nntp.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!bloom-beacon.mit.edu!newsswitch.lcs.mit.edu!nntp.TheWorld.com!.POSTED!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Is Text_IO.Put_Line() thread-safe? Date: Thu, 14 Jun 2012 14:24:49 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <93201f1a-d668-485e-83b4-492bc283f36e@googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 X-Trace: pcls6.std.com 1339698289 31299 192.74.137.71 (14 Jun 2012 18:24:49 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Thu, 14 Jun 2012 18:24:49 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:nwHWbvbDsI/bndL6abXSzgiYiRg= Content-Type: text/plain; charset=us-ascii Date: 2012-06-14T14:24:49-04:00 List-Id: awdorrin 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