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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,e0e1d3b3f7c994b8 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Alex R. Mosteo" Newsgroups: comp.lang.ada Subject: Re: Robert Dewar's great article about the Strengths of Ada over other langauges in multiprocessing! Date: Thu, 13 Mar 2008 14:03:50 +0100 Message-ID: <63sn1tF29a5oiU1@mid.individual.net> References: <13t4b2kkjem20f3@corp.supernews.com> <89af8399-94fb-42b3-909d-edf3c98d32e5@n75g2000hsh.googlegroups.com> <2c2989ba-a109-40d6-b0a3-f91d94a2d291@a1g2000hsb.googlegroups.com> <47d906b4$0$1804$4d3efbfe@news.sover.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: individual.net 9znU8gSWYNdZv6gMLYfHXQSuamuraNdOZRAvNR2+crTDy+wMk= Cancel-Lock: sha1:yv+FhlVZalaLhCIJTvmIGONTc5Q= User-Agent: KNode/0.10.5 Xref: g2news1.google.com comp.lang.ada:20344 Date: 2008-03-13T14:03:50+01:00 List-Id: Peter C. Chapin wrote: > This paper: > > http://www.aristeia.com/Papers/DDJ_Jul_Aug_2004_revised.pdf > > describes some of these issues in a C++ context and is written by two > authors who probably know what they are talking about. Their conclusion > is that it is pretty much impossible to write correct multi-threaded > code in C++ without (non-standard) compiler assistance. I'm paraphrasing > here. It is my understanding, however, that this matter will be > addressed in C++ 0x. > > Peter After reading the pointers given in this thread, I'm under the impression that indeed you need to use volatile for unprotected variables accessed across threads? For, example, in Ada: declare Global_Exit : Boolean := False; -- pragma Volatile (Global_Exit); -- pragma Atomic (Global_Exit); begin -- Lots o'tasks here that monitor Global_Exit for termination. end; Here you don't need a protected, since once someone makes Global_Exit true, the end arrives and all is well. I would normally mark that as Atomic which, as it implies volatile, is OK. But let's say one knows that boolean is atomic for the architecture, and makes the (risky) decision of not explicitly saying so to the compiler. I understand that, without volatile, tasks never writing to Global_Exit could optimize away any check for changes on it, and see it as a constant? (Indeed I guess Gnat would issue a warning about Global_Exit being constant). Although in Ada I don't see much (or any?) use for volatile, non-atomic shared variables outside of protected objects. Some flaw in my understanding?