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,e0e1d3b3f7c994b8 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!m34g2000hsc.googlegroups.com!not-for-mail From: gpriv@axonx.com 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 07:02:42 -0700 (PDT) Organization: http://groups.google.com Message-ID: <02c836da-4b31-48ad-acb8-433180341cb1@m34g2000hsc.googlegroups.com> 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> <63sn1tF29a5oiU1@mid.individual.net> NNTP-Posting-Host: 151.196.71.114 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1205416962 1537 127.0.0.1 (13 Mar 2008 14:02:42 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 13 Mar 2008 14:02:42 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: m34g2000hsc.googlegroups.com; posting-host=151.196.71.114; posting-account=YaY8rAoAAAAAnFXOECY3BGVJsrvFJCgy User-Agent: G2/1.0 X-HTTP-Via: 1.1 SPARKS X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:20345 Date: 2008-03-13T07:02:42-07:00 List-Id: On Mar 13, 9:03 am, "Alex R. Mosteo" wrote: > 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? You are correct you should use volatiles. I don't think there is any need to have volatile inside the protected objects. Access will be properly serialized anyway. G.