Andrew Pinski <pins...@gmail.com> writes:

> On Sat, Feb 2, 2013 at 5:10 PM, Jeffrey Walton <noloa...@gmail.com> wrote:
>> Thanks Andrew.
>>
>> So, it looks like I don't understand sequence points. Please forgive
>> my ignorance.
>>
>> What does C/C++ and GCC offer to ensure writes are complete before
>> reads are performed on a value in a multi-threaded program?
>
> GCC offers some builtins which start with __atomic_* (older versions
> of GCC [4.2.x-4.6.x] only offer __sync_* builtins functions).  C++11
> offers some atomic functions too (which in turn calls the __atomic_*
> functions).  I don't remember if C11 offers those similar functions or
> not.

Even atomics do not guarantee that writes are finished before any 
other read on other threads. There's usually no way to do that
in modern computer architectures (except for MMIO), 
short of adding an explicit  dependency. Typically you don't want to 
do it anyways for performance reasons.

But that's off topic for this mailing list and should
probably be discussed somewhere else.

-Andi

-- 
a...@linux.intel.com -- Speaking for myself only

Reply via email to