On Thu, 11 Jun 2015 12:21:23 +0100 Andrew Haley <aph@xxxxxxxxxx> wrote: > I'd use a full memory barrier. __sync_synchronize() Isn't __sync_synchronize() the same as a memory clobber + hardware barrier? > Even if your processor does not use a relaxed > memory model, It doesn't, so I'm not much concerned about hardware barriers, and assume it's ok to continue to use the macros provided in avr-libc, assuming the implementers of that knew their job. > this guarantees that no memory operations will not > be moved across the barrier. Still the open question: Is access to array elements (or dereferencing a pointer) always considered a "memory operation", unlike the variable access in the example in [2]? > or one of the __atomic fences. As far as I can see, you can only use them on integers or pointers, but not on arrays. So you think it would be enough to do the pointer manipulations atomically, and then the array accesses which depend on these pointers should be ok? That's what I'm thinking, too, but what I'm not sure about... [2]: http://www.nongnu.org/avr-libc/user-manual/optimization.html Sebastian