From: Jere <jhb.chat@gmail.com>
Subject: Re: Portable memory barrier?
Date: Wed, 10 May 2017 16:40:05 -0700 (PDT)
Date: 2017-05-10T16:40:05-07:00 [thread overview]
Message-ID: <af131a68-2150-49a6-9ac2-273a3933cfc4@googlegroups.com> (raw)
In-Reply-To: <oevfgl$l66$1@dont-email.me>
On Wednesday, May 10, 2017 at 12:38:54 PM UTC-4, Jeffrey R. Carter wrote:
> On 05/10/2017 02:51 AM, Jere wrote:
> >
> > Is there a method besides Atomic? If I am implementing a generic FIFO (lock
> > free) and the FIFO elements are complex data types that may not be able to be
> > atomic, do I have any other options or are protected objects my only way out?
>
> If your indices are Atomic and your array has Volatile_Components, then I think
> things will work the way you want them to. The important reference here is ARM
> 1.1.3, which says
>
> * Any read or update of an atomic or volatile object is part of the program's
> external interactions.
>
> * An Ada compiler must produce a program with external interactions in the order
> and timing specified by Ada's semantics.
>
> Ada's semantics for a sequence of statements say the statements are executed in
> order.
>
> So, if you have in task A
>
> A (I + 1) := Item;
> I := I + 1;
>
> Then from the outside an observer must see in order
>
> 1. Read I
> 2. Write A (I + 1)
> 3. Read I
> 4. Write I
>
> If task B does
>
> if I > 0 then
>
> then B's "Read I" will also be something the external observer can see. It might
> happen before 1., between 1. and 3., between 3. and 4., or after 4., but won't
> happen during any of 1, 3, or 4. That guarantees that B will always get a valid
> view of I.
Thanks!
My previous couple of emails might be moot now that I have read this response.
Here I get the impression that Volatile does prevent Compiler statement
reordering. If that is the case, then I know between that and any fencing put
up by Atomic objects will be sufficient.
So at this point my understanding is now:
Type => Prevents Compiler Reordering => Prevents CPU Reordering
Volatile => YES => NO
Atomic => YES => YES
next prev parent reply other threads:[~2017-05-10 23:40 UTC|newest]
Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-06 2:23 Portable memory barrier? Jere
2017-05-06 8:47 ` Jeffrey R. Carter
2017-05-06 14:17 ` Jere
2017-05-06 19:08 ` Dennis Lee Bieber
2017-05-06 19:26 ` Jeffrey R. Carter
2017-05-06 19:41 ` Jeffrey R. Carter
2017-05-06 20:42 ` Niklas Holsti
2017-05-09 19:49 ` Randy Brukardt
2017-05-09 22:07 ` Jere
2017-05-11 1:14 ` Randy Brukardt
2017-05-10 18:28 ` Shark8
2017-05-11 1:17 ` Randy Brukardt
2017-05-11 16:23 ` Jeffrey R. Carter
2017-05-07 20:18 ` Robert Eachus
2017-05-08 7:45 ` Dmitry A. Kazakov
2017-05-08 15:56 ` Robert Eachus
2017-05-08 16:22 ` Dmitry A. Kazakov
2017-05-08 18:39 ` Robert Eachus
2017-05-08 19:18 ` Robert Eachus
2017-05-08 21:09 ` Dmitry A. Kazakov
2017-05-08 23:24 ` Robert Eachus
2017-05-09 0:30 ` Jere
2017-05-09 4:02 ` Robert Eachus
2017-05-09 4:32 ` Robert Eachus
2017-05-09 4:44 ` Robert Eachus
2017-05-09 22:26 ` Jere
2017-05-09 20:01 ` Randy Brukardt
2017-05-09 19:57 ` Randy Brukardt
2017-05-10 0:51 ` Jere
2017-05-10 5:25 ` J-P. Rosen
2017-05-10 22:56 ` Jere
2017-05-11 7:36 ` Dmitry A. Kazakov
2017-05-13 20:25 ` Jere
2017-05-10 7:13 ` Dmitry A. Kazakov
2017-05-10 16:45 ` Robert Eachus
2017-05-10 17:28 ` Simon Wright
2017-05-10 23:21 ` Jere
2017-05-11 0:47 ` Randy Brukardt
2017-05-13 20:11 ` Jere
2017-05-15 22:33 ` Randy Brukardt
2017-05-10 23:30 ` Jere
2017-05-11 0:38 ` Randy Brukardt
2017-05-10 16:38 ` Jeffrey R. Carter
2017-05-10 23:40 ` Jere [this message]
2017-05-10 16:19 ` Robert Eachus
2017-05-11 1:02 ` Randy Brukardt
2017-05-11 1:51 ` Robert Eachus
2017-05-15 22:45 ` Randy Brukardt
2017-05-08 20:29 ` Niklas Holsti
2017-05-08 21:09 ` Dmitry A. Kazakov
2017-05-09 4:34 ` Niklas Holsti
2017-05-09 6:16 ` Niklas Holsti
2017-05-09 8:34 ` Dmitry A. Kazakov
2017-05-09 20:18 ` Randy Brukardt
2017-05-09 20:10 ` Randy Brukardt
2017-05-09 0:05 ` Jere
2017-05-09 8:26 ` Dmitry A. Kazakov
2017-05-09 19:53 ` Randy Brukardt
2017-05-09 20:27 ` Dmitry A. Kazakov
2017-05-11 0:35 ` Randy Brukardt
2017-05-11 8:24 ` Dmitry A. Kazakov
2017-05-15 22:53 ` Randy Brukardt
2017-05-18 17:44 ` Dmitry A. Kazakov
2017-05-18 21:01 ` Randy Brukardt
2017-05-19 7:54 ` Dmitry A. Kazakov
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox