InterlockedExchangeAdd

LONG
InterlockedExchangeAdd(
IN OUT PLONG
Addend,
IN LONG Value
);

InterlockedExchangeAdd adds a value to a given integer as an atomic operation and returns the initial value of the given integer.

Parameters

Addend

Points to an integer that will have Value added to it.

Value

Is the value to be added to Addend.

Return Value

InterlockedExchangeAdd returns the original (unsummed) value of the Addend variable.

Comments

This routine should be used in place of the previous ExInterlockedAddUlong. 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 InterlockedExchangeAdd routine is atomic only with respect to other InterlockedXxx calls.

Callers of InterlockedExchangeAdd run at any IRQL.

See Also

InterlockedIncrement, InterlockedDecrement, ExInterlockedAddLargeInteger, ExInterlockedAddUlong