I came across the function InterlockedExchange and was wondering when I should use this function. In my opinion, setting a 32 Bit value on an x86 processor should always be atomic?
In the case where I want to use the function, the new value does not depend on the old value (it is not an increment operation). Could you provide an example where this method is mandatory (I’m not looking for InterlockedCompareExchange)
I came across the function InterlockedExchange and was wondering when I should use this
Share
In a multi-processor or multi-core machine each core has it’s own cache – so each core has each own potentially different ‘view’ of what the content of the system memory is.
Thread synchronization mechanisms take care of synchronizing between cores, for more information look at http://blogs.msdn.com/oldnewthing/archive/2008/10/03/8969397.aspx or google for acquire and release semantics