1,885
edits
Changes
no edit summary
GCC provides [[Compiler Intrinsics|intrinsics]] for some atomic operations.
(Note that in the above example, even the <code>lock++</code> instructions may not be atomic - it will typically compile into the three-operation sequence "load-increment-store", and its possible that two processes or threads could each perform this operation in an interleaved fashion and increment <code>lock</code> by just one instead of two).