Search code examples
c++multithreadingatomic

The usage of _InterlockedCompareExchange64


On MSDN, I see that

InterlockedCompareExchange64

requires parameters to be 64 aligned,

but for

_InterlockedCompareExchange64 

I see no such requirement for alignment, and it is mentioned to provide compiler intrinsic support for the InterlockedCompareExchange64.

So, does this means I can use _InterlockedCompareExchange64 without caring about alignment? 'Cause I don't quite know what alignment means here.


Solution

  • I'm pretty certain that is a documentation mistake, rather than any direct difference between the two function - seeing as they result in exactly the same CMPXCHG8B instruction. [Assuming of course you are looking for it it to actually be atomic on an SMP system - but it's a pretty specialized instruction, so I doubt it has much other use].