title: What does OSAtomicIncrement32 lock on?
body: <p>What does OSAtomicIncrement32 lock on? Does dispatch_async cause atomic calls to be not thread safe for the original variable?</p>
  
  <pre><code>static volatile int32_t count;
  ...
  dispatch_async(dispatch_get_main_queue(), ^{
    ...
    OSAtomicIncrement32(&amp;count);
  }
  </code></pre>
  
  <p>Is volatile redundant, or could some threads read an old value even if count is always atomically incremented?</p>
  
  <p>Edit: the volatile question was cleared up by <a href="http://www.drdobbs.com/parallel/volatile-vs-volatile/212701484" rel="nofollow">http://www.drdobbs.com/parallel/volatile-vs-volatile/212701484</a>. That can be found by following several links in the answer, but thought I'd post it here for quick reference. In short, 'volatile' does not mean the same thing in Java as in Objective-C.</p>