comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <rm.dash-bauhaus@futureapps.de>
Subject: Re: About task-safeness
Date: Thu, 03 Feb 2011 12:07:52 +0100
Date: 2011-02-03T12:07:52+01:00	[thread overview]
Message-ID: <4d4a8c88$0$6773$9b4e6d93@newsspool3.arcor-online.net> (raw)
In-Reply-To: <8qv8neF9i0U1@mid.individual.net>

On 03.02.11 09:53, Niklas Holsti wrote:
> Randy Brukardt wrote:
>> "mockturtle" <framefritti@gmail.com> 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.



  reply	other threads:[~2011-02-03 11:07 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-02 20:51 About task-safeness mockturtle
2011-02-02 21:01 ` Vinzent Hoefler
2011-02-02 21:14   ` mockturtle
2011-02-02 22:16     ` Maciej Sobczak
2011-02-02 22:28       ` Shark8
2011-02-02 22:40         ` Peter C. Chapin
2011-02-03  8:33           ` Dmitry A. Kazakov
2011-02-03 17:59       ` Vinzent Hoefler
2011-02-02 22:38 ` J-P. Rosen
2011-02-03  2:44 ` Randy Brukardt
2011-02-03  8:53   ` Niklas Holsti
2011-02-03 11:07     ` Georg Bauhaus [this message]
2011-02-03 11:22       ` AdaMagica
2011-02-03 18:13         ` Jeffrey Carter
2011-02-04  0:33     ` Randy Brukardt
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox