ExInterlockedAddUlong routine

The ExInterlockedAddUlong routine adds an unsigned long value to a given unsigned integer as an atomic operation.

Syntax

ULONG ExInterlockedAddUlong(
  _Inout_ PULONG      Addend,
  _In_    ULONG       Increment,
  _Inout_ PKSPIN_LOCK Lock
);

Parameters

  • Addend [in, out]
    A pointer to an unsigned long integer whose value is to be adjusted by the Increment value.

  • Increment [in]
    Specifies an unsigned long integer to be added.

  • Lock [in, out]
    A pointer to a spin lock to be used to synchronize access to the Addend.

Return value

ExInterlockedAddUlong returns the original (unsummed) value of the Addend.

Remarks

Consider using InterlockedExchangeAdd instead of this routine. InterlockedExchangeAdd can be more efficient because it does not use a spin lock and it is inlined by the compiler.

Support routines that do interlocked operations are assumed to be incapable of causing a page fault. That is, neither their code nor any of the data they touch can cause a page fault without bringing down the system. They use spin locks to achieve atomicity on symmetric multiprocessor machines. The caller must provide resident storage for the Lock, which must be initialized with KeInitializeSpinLock before the initial call to an ExInterlockedXxx.

The Lock passed to ExInterlockedAddULong is used to assure that the add operation on Addend is atomic with respect to any other operations on the same value which synchronize with this same spin lock.

ExInterlockedAddUlong masks interrupts. Consequently, it can be used for synchronization between an ISR and other driver code, provided that the same Lock is never reused in a call to a routine that runs at IRQL = DISPATCH_LEVEL.

Note that calls to InterlockedXxx are guaranteed to be atomic with respect to other InterlockedXxx calls without caller-supplied spin locks.

Callers of ExInterlockedAddUlong run at any IRQL. The storage for the Addend parameter must be resident at all IRQLs.

Requirements

Target platform

Universal

Version

Available starting with Windows 2000.

Header

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

Library

NtosKrnl.lib

DLL

NtosKrnl.exe

IRQL

Any level (see Remarks section)

See also

ExInterlockedAddLargeInteger

InterlockedIncrement

InterlockedDecrement

KeInitializeSpinLock

 

 

Send comments about this topic to Microsoft