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: a07f3367d7,4fe1e6b66c35dfe2 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!feeder.news-service.com!newsfeed.straub-nv.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Thu, 03 Feb 2011 12:07:52 +0100 From: Georg Bauhaus User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: About task-safeness References: <06ecb5ab-a9e5-4a5d-9370-6bbe137d3693@glegroupsg2000goo.googlegroups.com> <8qv8neF9i0U1@mid.individual.net> In-Reply-To: <8qv8neF9i0U1@mid.individual.net> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Message-ID: <4d4a8c88$0$6773$9b4e6d93@newsspool3.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 03 Feb 2011 12:07:52 CET NNTP-Posting-Host: bdb8dfc3.newsspool3.arcor-online.net X-Trace: DXC=IIf10[]e>J2^8FBo0_81f>McF=Q^Z^V384Fo<]lROoR18kFkKdk>nc\616M64>:Lh>_cHTX3j=a8=Z35l6=62 X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:17815 Date: 2011-02-03T12:07:52+01:00 List-Id: On 03.02.11 09:53, Niklas Holsti wrote: > Randy Brukardt wrote: >> "mockturtle" wrote in message >> news:06ecb5ab-a9e5-4a5d-9370-6bbe137d3693@glegroupsg2000goo.googlegroups.com... >> ... >>> (For example, a package defining some type of object could keep the number >>> of allocated >>> objects, so it can give to each object a unique ID.) If such a package was >>> used by two >>> different tasks, and the counter was not protected, obscure bugs can arise. >>> This type of >>> structure maybe is not very recommended, but it happens... :-( >> >> Note that "protection" may simply be declaring the object Atomic. Presuming >> the compiler supports that, there isn't a problem with multiple tasks >> accessing the same counter. > > Randy, could you be more explicit about your suggested use of Atomic? As I > understand it, even if a counter variable N is Atomic, two tasks concurrently > executing an assignment of the form > > N := N + 1; > > can interleave their actions so that N is increased by only 1, not by 2 as > intended. When I first read about atomic counting, I thought so, too. But then, I noticed a new(?) Implementation Advice in the LRM that says, IIRC, that compilers should make atomic processor ops available, including decrement. A neighboring paragraph is about intrinsic operations.