Expand Minimize
This topic has not yet been rated - Rate this topic

InterlockedExchangeAdd routine

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

Syntax


LONG InterlockedExchangeAdd(
  _Inout_  LONG volatile *Addend,
  _In_     LONG Value
);

Parameters

Addend [in, out]

A pointer to an integer variable.

Value [in]

Specifies the value to be added to Addend.

Return value

InterlockedExchangeAdd returns the original value of the Addend variable when the call occurred.

Remarks

InterlockedExchangeAdd should be used instead of ExInterlockedAddUlong because it is both faster and more efficient.

InterlockedExchangeAdd 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.

InterlockedExchangeAdd is atomic only with respect to other InterlockedXxx calls.

Interlocked operations cannot be used on non-cached memory.

Requirements

Version

Available starting with Windows 2000.

Header

Wdm.h (include Wdm.h, Ntddk.h, or Ntifs.h)

IRQL

Any level

See also

InterlockedDecrement
InterlockedIncrement
ExInterlockedAddLargeInteger
ExInterlockedAddUlong

 

 

Send comments about this topic to Microsoft

Build date: 5/22/2013

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.