Partager via


Interlocked Functions (Windows CE 5.0)

Send Feedback

Interlocked functions synchronize access to a variable that is shared by multiple threads.

Their purpose is to prevent a thread from being preempted while it is incrementing or checking a variable.

The threads of different processes can use these functions as long as their variables share memory.

Windows CE supports eight interlocked functions:

The following table describes the tasks that you can perform with each function.

To Call
Increment a shared variable and check the resulting value InterlockedIncrement
Decrement a shared variable and check the resulting value InterlockedDecrement
Exchange the values of specified variables InterlockedExchange
Exchange the values of specified variables if one variable is equal to a specified value InterlockedTestExchange
Compare the values of specified values and exchange the values based on the outcome InterlockedCompareExchange
Perform an atomic addition of an increment value to an addend value InterlockedExchangeAdd
Perform an atomic comparison of specified values and exchange the values based on the outcome of the comparison InterlockedCompareExchangePointer
Atomically exchange a pair of values InterlockedExchangePointer

See Also

Synchronization

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.