Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>One of the issues is the definition of "memory location", that allows (and forces the compiler to support) locking different structure members by different locks. There is a <a href="http://gcc.gnu.org/ml/gcc/2012-02/msg00005.html" rel="noreferrer">discussion about a RL problem caused by this</a>.</p> <p>Basically the issue is that having a <code>struct</code> defined like this:</p> <pre><code>struct x { long a; unsigned int b1; unsigned int b2:1; }; </code></pre> <p>the compiler is free to implement writing to <code>b2</code> by overwriting <code>b1</code> too (and apparently, judging from the report, it does). Therefore, the two fields have to be locked as one. However, as a consequence of the C++11 memory model, this is forbidden (well, not really forbidden, but the compiler must ensure simultaneous updates to <code>b1</code> and <code>b2</code> do not interfere; it could do it by locking or CAS-ing each such update, well, life is difficult on some architectures). Quoting from the report:</p> <blockquote> <p>I've raised the issue with our GCC guys and they said to me that: "C does not provide such guarantee, nor can you reliably lock different structure fields with different locks if they share naturally aligned word-size memory regions. The C++11 memory model would guarantee this, but that's not implemented nor do you build the kernel with a C++11 compiler."</p> </blockquote> <p>Nice info can also be found in the <a href="http://gcc.gnu.org/wiki/Atomic/GCCMM" rel="noreferrer">wiki</a>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload