PVOID
InterlockedCompareExchange(
IN OUT PVOID *Destination,
IN PVOID Exchange,
IN PVOID Comperand
);
InterlockedCompareExchange compares a pointer value (Comperand) with a destination pointer value (Destination). If the values are equal, then a third pointer value (Exchange) is stored in the destination. Otherwise, no operation is performed. The compare and exchange operations are performed in an atomic operation.
InterlockedCompareExchange returns the original destination value.
InterlockedCompareExchange provides an atomic way to test a value and update it if the test passes. This routine is implemented inline by the compiler when appropriate and possible. It does not require a spin lock and can therefore be safely used on pageable data.
The InterlockedCompareExchange routine is atomic only with respect to other InterlockedXxx calls.
Callers of InterlockedCompareExchange run at any IRQL.
InterlockedIncrement, InterlockedDecrement, InterlockedExchange