// miniport.h
LONG InterlockedCompareExchange(
[in, out] LONG volatile *Destination,
LONG ExChange,
LONG Comperand
);
View the official Windows Driver Kit DDI reference
// wdm.h
LONG CDECL_NON_WVMPURE InterlockedCompareExchange(
[in, out] LONG volatile *Destination,
[in] LONG ExChange,
[in] LONG Comperand
);
View the official Windows Driver Kit DDI reference
No description available.
The InterlockedCompareExchange routine performs an atomic operation that compares the input value pointed to by Destination with the value of Comparand.
Destination
[in, out]A pointer to the input value that is compared with the value of Comparand.
ExChange
Specifies the output value pointed to by Destination if the input value pointed to by Destination equals the value of Comparand.
Comperand
Specifies the value that is compared with the input value pointed to by Destination.
InterlockedCompareExchange returns the original value of *Destination.
If Comparand is equal to *Destination, then *Destination is set to equal Exchange. Otherwise, *Destination is unchanged.
InterlockedCompareExchange provides a fast, atomic way to synchronize the testing and updating of a variable that is shared by multiple threads. If the input value pointed to by Destination equals the value of Comparand, the output value of Destination is set to the value of Exchange.
InterlockedCompareExchange is designed for speed and, typically, is implemented inline by a compiler. InterlockedCompareExchange is atomic only with respect to other InterlockedXxx calls. It does not use a spin lock and can be safely used on pageable data.
Interlocked operations cannot be used on non-cached memory.
ExInterlockedCompareExchange64
InterlockedCompareExchangePointer
The InterlockedCompareExchange routine performs an atomic operation that compares the input value pointed to by Destination with the value of Comperand.
Destination
[in, out]A pointer to the input value that is compared with the value of Comperand.
ExChange
[in]Specifies the output value pointed to by Destination if the input value pointed to by Destination equals the value of Comperand.
Comperand
[in]Specifies the value that is compared with the input value pointed to by Destination.
InterlockedCompareExchange returns the original value of *Destination.
If Comperand is equal to *Destination, then *Destination is set to equal Exchange. Otherwise, *Destination is unchanged.
InterlockedCompareExchange provides a fast, atomic way to synchronize the testing and updating of a variable that is shared by multiple threads. If the input value pointed to by Destination equals the value of Comperand, the output value of Destination is set to the value of Exchange.
InterlockedCompareExchange is designed for speed and, typically, is implemented inline by a compiler. InterlockedCompareExchange is atomic only with respect to other InterlockedXxx calls. It does not use a spin lock and can be safely used on pageable data.
Interlocked operations cannot be used on non-cached memory.
ExInterlockedCompareExchange64
InterlockedCompareExchangePointer