title: "Weak" atomic operations?
body: <p>In the new <code>C++11</code> standard, many atomic operations are defined in "strong/weak" pairs:</p>
  
  <pre><code>template&lt; class T &gt;
  bool atomic_compare_exchange_weak( std::atomic&lt;T&gt;* obj, 
                                     T* expected, T desired );
  template&lt; class T &gt;
  bool atomic_compare_exchange_weak( volatile std::atomic&lt;T&gt;* obj, 
                                     T* expected, T desired );
  </code></pre>
  
  <p>I understand that the weak one may be faster, but may fail occasionally, so one needs to put it into a <code>while</code> loop like below (taken from cppreference):</p>
  
  <pre><code>void append(list* s, node* n)
  {
      node* head;
      do {
          head = s-&gt;head;
          n-&gt;next = head;
      } while(! std::atomic_compare_exchange_weak(s-&gt;head, head, n));
  }
  </code></pre>
  
  <p><strong>But</strong></p>
  
  <ol>
  <li><p>What exactly do the weak operations do? Why do they sometimes fail, and why are they faster? (I would love some hardcore microprocessor architecture details.)</p></li>
  <li><p>When is the weak form preferable, and when is the strong one recommended?</p></li>
  </ol>