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=0.4 required=5.0 tests=BAYES_00,FORGED_MUA_MOZILLA autolearn=no 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.219.170 with SMTP id pp10mr4950356pbc.1.1339738341074; Thu, 14 Jun 2012 22:32:21 -0700 (PDT) Path: l9ni52466pbj.0!nntp.google.com!news2.google.com!goblin2!goblin.stu.neva.ru!news.teledata-fn.de!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Fri, 15 Jun 2012 07:32:14 +0200 From: Georg Bauhaus User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Is Text_IO.Put_Line() thread-safe? References: <93201f1a-d668-485e-83b4-492bc283f36e@googlegroups.com> <546fc310-c898-417a-9c92-a5b12ef32591@googlegroups.com> In-Reply-To: Message-ID: <4fdac8dc$0$9508$9b4e6d93@newsspool1.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 15 Jun 2012 07:32:12 CEST NNTP-Posting-Host: ee5b1116.newsspool1.arcor-online.net X-Trace: DXC=N5nk38Y?=m?L2C_`koXfC5ic==]BZ:af>4Fo<]lROoR1nkgeX?EC@@0JkkRih[6ejV80HeH>ef77;1OO7^22mA6P0 X-Complaints-To: usenet-abuse@arcor.de Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Date: 2012-06-15T07:32:12+02:00 List-Id: On 14.06.12 23:37, Robert A Duff wrote: > awdorrin writes: > >> That is what I mean, if the Text_IO.Put_Line isn't thread-safe, and >> its picking up data from the array being sorted in the other thread, >> and printing it, then it very well could have written the information >> it was supposed to be printing to the screen, into that array that was >> being sorted... Anything could be corrupted. > > Yes. It doesn't seem likely to me, but it could happen. > More likely (I'm guessing) is that there's another bug, somewhere > other than the Put_Lines. > >> I really cannot believe that the Put_Line's aren't thread safe. > > Yes, there are several things wrong with the design of Text_IO, > and this is one of them. But it's not too hard to work around it. But surely I/O routines in general should not be thread safe and thus have to drag in everything required to achieve thread safety? The result is still likely not safe, after all, if one can duplicate file descriptors, or is unaware of others writing to the same file, such as a log file. Neither does the thread safety of single Text_IO calls make sequences of Text_IO calls behave atomically. Assuming Num_IO.Put and New_Line to be thread safe, Num_IO.Put (123); -- (1) New_Line; -- (2) What has happened between (1) and (2)? An atomic sequence in a dedicated I/O task looks just right to me. A program sprinkled with I/O calls because, well, they are thread safe, is a good predictor of maintenance nightmares, as it lacks modularity and separation of concerns.