Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualParadigm Shifter

Posted 01 November 2013 - 06:45 PM

You can get task switched to another thread after any instruction (an if and assignment can be several instructions long), so you need to do the check and the set of the new value in a single instruction.

 

Like this

InterlockedCompareExchange function

 

http://msdn.microsoft.com/en-us/library/windows/desktop/ms683560%28v=vs.85%29.aspx


#2Paradigm Shifter

Posted 01 November 2013 - 06:44 PM

You can get task switched to another thread after any instruction, so you need to do the check and the set of the new value in a single instruction.

 

Like this

InterlockedCompareExchange function

 

http://msdn.microsoft.com/en-us/library/windows/desktop/ms683560%28v=vs.85%29.aspx


#1Paradigm Shifter

Posted 01 November 2013 - 06:43 PM

You can get task switched to another thread after any instruction, so you need to do the check and the set of the new value in a single instruction.

 

Like this

InterlockedCompareExchange function

 

http://msdn.microsoft.com/en-us/library/windows/desktop/ms683560%28v=vs.85%29.aspx


PARTNERS