_InterlockedExchange (Windows CE 5.0)

Send Feedback

This function atomically exchanges a pair of 32-bit values. The function prevents more than one thread from using the same variable simultaneously.

LONG InterlockedExchange(  LONG volatile*Target,  LONG Value);

Parameters

  • Target
    [in, out] Pointer to the value to be exchanged. The function sets this variable to Value, and returns its prior value.
  • Value
    [in] Value to be exchanged with the value pointed to by Target.

Return Values

The function returns the initial value of the target.

Remarks

The interlocked functions provide a simple mechanism for synchronizing access to a variable that is shared by multiple threads. The threads of different processes can use this mechanism if the variable is in shared memory.

The variable pointed to by the Target parameter must be aligned on a 32-bit boundary; otherwise, this function will fail on multiprocessor x86 systems and any non-x86 systems.

This function should not be used on memory allocated with the PAGE_NOCACHE modifier.

Requirements

Header: winbase.h.

See Also

Intrinsic Functions for MIPS Microprocessors

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.