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: g2news1.google.com!news4.google.com!feeder.news-service.com!newsfeed.kamp.net!newsfeed.kamp.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: About task-safeness Date: Thu, 03 Feb 2011 09:53:03 +0100 Organization: Tidorum Ltd Message-ID: <8qv8neF9i0U1@mid.individual.net> References: <06ecb5ab-a9e5-4a5d-9370-6bbe137d3693@glegroupsg2000goo.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net SIHSpRhtogrhV3O47GP4NwPYfku5L+FxVwifWODs2Mel7V5O5U Cancel-Lock: sha1:y1Gaj44W4CwiQOJ8347bQebUn80= User-Agent: Mozilla-Thunderbird 2.0.0.24 (X11/20100328) In-Reply-To: Xref: g2news1.google.com comp.lang.ada:16839 Date: 2011-02-03T09:53:03+01:00 List-Id: 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. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .