Platform SDK: DLLs, Processes, and Threads |
The InterlockedExchangePointer function atomically exchanges a pair of values. The function prevents more than one thread from using the same variable simultaneously.
If you are exchanging pointer values, this function supersedes the InterlockedExchange function.
PVOID InterlockedExchangePointer( PVOID *Target, // value to exchange PVOID Value // new value );
The function returns the initial value pointed to by Target.
On a 64-bit system, the parameters are 64 bits and must be aligned on 64-bit boundaries; otherwise, the function will fail. On a 32-bit system, the parameters are 32 bits and must be aligned on 32-bit boundaries.
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.
Windows NT/2000: Requires Windows NT 3.5 or later.
Windows 95/98: Requires Windows 95 or later.
Header: Declared in Winbase.h; include Windows.h.
Library: Use Kernel32.lib.
Synchronization Overview, Synchronization Functions, Interlocked Variable Access, InterlockedCompareExchange, InterlockedCompareExchangePointer, InterlockedDecrement, InterlockedExchange, InterlockedExchangeAdd, InterlockedIncrement