MacOSX: OSAtomic vs OSAtomicBarrier

Posted by anon on Stack Overflow See other posts from Stack Overflow or by anon
Published on 2010-03-12T23:19:40Z Indexed on 2010/03/12 23:27 UTC
Read the original article Hit count: 232

Filed under:
|

For the functions here:

#include <libkern/OSAtomic.h>

there are OSAtomic and OSAtomicBarrier versions.

However, the documentation does not show sample code for:

  1. When is it safe to use just OSAtomic, without the OSAtomicBarrier version
  2. When is it that OSAtomic would be unsafe, but OSAtomiBarrier would be safe.

Can anyone provide explainations + sample codes?

[Random ramblings of "your opinion" without actual code is useless. Readers: please down vote such answers; and vigrously upvote answers with actual code.]

[C/C++ code preferred; Assembly okay too.]

© Stack Overflow or respective owner

Related posts about osatomic

Related posts about osatomicbarrier