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!news2.google.com!news.glorb.com!news.tele.dk!feed118.news.tele.dk!news.tele.dk!small.news.tele.dk!fi.sn.net!newsfeed2.fi.sn.net!news.song.fi!not-for-mail Date: Tue, 11 Mar 2008 00:30:01 +0200 From: Niklas Holsti User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20060628 Debian/1.7.8-1sarge7.1 X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Robert Dewar's great article about the Strengths of Ada over other langauges in multiprocessing! References: <13t4b2kkjem20f3@corp.supernews.com> <89af8399-94fb-42b3-909d-edf3c98d32e5@n75g2000hsh.googlegroups.com> <47D39DC8.20002@obry.net> <1lbnckly14ak1$.1toakcw8jw12$.dlg@40tude.net> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <47d5b633$0$15002$4f793bc4@news.tdc.fi> Organization: TDC Internet Services NNTP-Posting-Host: laku61.adsl.netsonic.fi X-Trace: 1205188147 news.tdc.fi 15002 81.17.205.61:32943 X-Complaints-To: abuse@tdcnet.fi Xref: g2news1.google.com comp.lang.ada:20283 Date: 2008-03-11T00:30:01+02:00 List-Id: Randy Brukardt wrote: > "Vadim Godunko" wrote in message > news:ec684efe-61a6-4463-bd43-fb5895e868bc@x30g2000hsd.googlegroups.com... >> >>I have attach all source code. Protected object used for atomic >>reference counting... > > If you need an atomic component, why didn't you just declare it as such and > let the compiler handle the mess? (Yes, an implementation is allowed to > reject pragma Atomic if it can't handle such, but that should always be OK > for an integer counter.) A protected object is going to be much heavier than > Atomic (which just uses the hardware support directly). > > ... > type Private_Data is record > --Counter : aliased League.Internals.Atomics.Counter; > Counter : Natural := 0; > pragma Atomic (Counter); That won't work if the Counter is used for reference counts. Vadim's code has parts like Self.Value := Self.Value - 1; Zero := Self.Value = 0; and pragma Atomic will not ensure that the whole sequence of statements and several uses of Self.Value are a single critical (uninterrupted) section. The pragma only means that the whole of Self.Value can be read or written atomically, even if it contains more than one storage unit. It does not ensure that Self.Value can be updated atomically. The sequence "read; modify; write" can be interrupted even with pragma Atomic. As Randy says in another message, pragma Atomic is good foor lock-free algorithms (if the memory order semantics are good) but it is not enough for lock-based algorithms such as Vadim is using. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .