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,DATE_IN_PAST_06_12 autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,534dd301375921ac X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.204.154.133 with SMTP id o5mr556261bkw.0.1339714577813; Thu, 14 Jun 2012 15:56:17 -0700 (PDT) Path: e27ni48974bkw.0!nntp.google.com!news1.google.com!news2.google.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nx01.iad01.newshosting.com!newshosting.com!novia!news-out.readnews.com!transit4.readnews.com!panix!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 09:49:45 -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 1339681785 18967 192.74.137.71 (14 Jun 2012 13:49:45 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Thu, 14 Jun 2012 13:49:45 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:kDHNo+2i74uD3QUj4agDqswV7I0= X-Received-Bytes: 2004 Content-Type: text/plain; charset=us-ascii Date: 2012-06-14T09:49:45-04:00 List-Id: awdorrin writes: > Text_IO.Put_Line( Proc_Enum'Image(thisPID)&" waiting for "& Proc_Enum'Image(waitPID)); Put_Line is not thread safe when called by multiple tasks on the same file. The file here is standard output. Standard output is a shared variable, so if you want to access it from multiple tasks, you need to synchronize. For example, you could have a single "debugging output" task, with a Put_Line entry, and call that from multiple tasks. The Put_Line entry could call Text_IO.Put_Line from within the rendezvous, or you could do some fancier buffering. You can call Put_Line from multiple tasks without synchronization if each task is writing to a different file. There's a logging facility that's part of gnatcoll, but I have never used it, and I don't know if it is thread safe. It's a good idea to put an exception handler at the bottom of every task body, and do some debugging output there. Otherwise, an exception will cause the task to silently vanish. This is a language design flaw. - Bob