Transition to C11 atomics and memory model

Joseph S. Myers joseph@codesourcery.com
Tue Sep 16 18:17:00 GMT 2014


On Sun, 14 Sep 2014, Torvald Riegel wrote:

> * All accesses to atomic vars need to use atomic_* functions.  IOW, all
> non-atomic accesses are not subject to data races.  The only exceptions
> is initialization (ie, when the variable is not visible to any other
> thread); nonetheless, initialization accesses must not result in data
> races with other accesses.  (This exception isn't allowed by C11, but
> eases the transition to C11 atomics and likely works fine in current
> implementations; as alternative, we could require MO-relaxed stores for
> initialization as well.)

Note <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63273> regarding 
MO-relaxed operations not being well-optimized.  It will be important to 
compare the code generated before and after any changes, and may be 
necessary to map the "relaxed" operations to plain loads and stores in 
some cases depending on the compiler version.

-- 
Joseph S. Myers
joseph@codesourcery.com



More information about the Libc-alpha mailing list