How can C++ compilers support C++11 atomic, but not support C++11 memory model -
while looking @ clang , g++ c++11 implementation status noticed strange:
support c++11 atomics, dont support c++11 memory model.
under impression must have c++11 memory model use atomics. difference between support atomics , memory model?
lack of memory model support means legal c++11 programs use std::atomic<t>
arent seq consistent?
references:
http://clang.llvm.org/cxx_status.html
http://gcc.gnu.org/gcc-4.7/cxx0x_status.html
one of issues definition of "memory location", allows (and forces compiler support) locking different structure members different locks. there discussion rl problem caused this.
basically issue having struct
defined this:
struct x { long a; unsigned int b1; unsigned int b2:1; };
the compiler free implement writing b2
overwriting b1
(and apparently, judging report, does). therefore, 2 fields have locked one. however, consequence of c++11 memory model, forbidden (well, not forbidden, compiler must ensure simultaneous updates b1
, b2
not interfere; locking or cas-ing each such update, well, life difficult on architectures). quoting report:
i've raised issue our gcc guys , said me that: "c not provide such guarantee, nor can reliably lock different structure fields different locks if share naturally aligned word-size memory regions. c++11 memory model guarantee this, that's not implemented nor build kernel c++11 compiler."
nice info can found in wiki.
Comments
Post a Comment