Is there a difference between :
__declspec(align(8)) long long variable1; //assume shared among threads
InterlockedIncrement64(&variable1);
And this:
__declspec(align(8)) long long volatile variable2;//assume shared among threads
InterlockedIncrement64(&variable2);
My guess would be that they operate exactly the same in this scenario. I think the only difference would be that if variable1
is accessed without an interlocked function it is not guaranteed to be a current value while variable2
is guaranteed to be a current value. Example:
long long x = variable1; //Not guaranteed to be the most recent value when accessed
long long y = variable2; //Guaranteed to be the most recent value when accessed
Am I correct in my assumptions? Note: I am using /volatile:ms compiler option in visual studio