Export (0) Print
Expand All
Expand Minimize

ExInterlockedCompareExchange64 routine

The ExInterlockedCompareExchange64 routine compares one integer variable to another and, if they are equal, sets the first variable to a caller-supplied value.

Syntax


LONGLONG ExInterlockedCompareExchange64(
  _Inout_  PLONGLONG Destination,
  _In_     PLONGLONG Exchange,
  _In_     PLONGLONG Comparand,
  _In_     PKSPIN_LOCK Lock
);

Parameters

Destination [in, out]

A pointer to an integer that will be compared and possibly replaced.

Exchange [in]

A pointer to an integer that will replace the one at Destination if the comparison results in equality.

Comparand [in]

A pointer to an integer with which the value at Destination will be compared.

Lock [in]

A pointer to a caller-allocated spin-lock that is used if the host system does not support an 8-byte atomic compare-and-exchange operation.

Return value

ExInterlockedCompareExchange64 returns the initial value of the variable at Destination when the call occurred.

Remarks

ExInterlockedCompareExchange64 tests and, possibly, replaces the value of a given variable. For most underlying microprocessors, this routine is implemented inline by the compiler to execute as an atomic operation. If a spin lock is used, this routine can only be safely used on nonpaged parameters.

If the Destination and Comparand are unequal, ExInterlockedCompareExchange64 simply returns the value of Destination.

ExInterlockedCompareExchange64 is atomic only with respect to other (Ex)InterlockedXxx calls.

Callers of ExInterlockedCompareExchange64 can be running at any IRQL. The storage for the Destination, Comparand, and Exchange parameter and the list entries must be resident at all IRQLs.

Requirements

Version

Available starting with Windows 2000.

Header

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

Library

Ntoskrnl.lib

IRQL

Any level (see Remarks section)

See also

InterlockedCompareExchange
InterlockedExchange
InterlockedExchangeAdd

 

 

Send comments about this topic to Microsoft

Show:
© 2014 Microsoft