InterlockedExchange

LONG
    InterlockedExchange(
        IN OUT PLONG
 Target,
        IN LONG Value
        );

InterlockedExchange sets an integer variable to a specified value as an atomic operation.

Parameters

Target
Points to a variable to be set to the supplied Value as an atomic operation.
Value
The caller-specified value to which Target is set.

Return Value

InterlockedExchange returns the original (unset) value of the Target variable.

Comments

This routine should be used in place of the previous ExInterlockedExchangeUlong. The new routine is faster and more efficient. It 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 InterlockedExchange routine is atomic only with respect to other InterlockedXxxxxx calls.

Callers of InterlockedExchange run at any IRQL.

See Also

InterlockedIncrement, InterlockedDecrement, ExInterlockedAddLargeInteger, ExInterlockedAddUlong