Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Visual Studio
Visual C++
C/C++ Languages
Compiler Intrinsics
 _InterlockedExchange Intrinsic Func...

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
Visual C++ Language Reference
_InterlockedExchange Intrinsic Functions

Microsoft Specific

Provide compiler intrinsic support for the Win32 Windows SDK InterlockedExchange function.

long _InterlockedExchange(
   long * Target,
   long Value
);
long _InterlockedExchange_acq(
   long * Target,
   long Value
);
__int64 _InterlockedExchange64(
   __int64 * Target,
   __int64 Value
);
__int64 _InterlockedExchange64_acq(
   __int64 * Target,
   __int64 Value
);
[in, out] Target

Pointer to the value to be exchanged. The function sets this variable to Value and returns its prior value.

[in] Value

Value to be exchanged with the value pointed to by Target.

Returns the initial value pointed to by Target.

Intrinsic

Architecture

_InterlockedExchange

x86, IPF, x64

_InterlockedExchange_acq

IPF

_InterlockedExchange64

IPF, x64

_InterlockedExchange64_acq

IPF

Header file <intrin.h>

There are several variations on _InterlockedExchange that vary based on the data types they involve and whether processor-specific acquire or release semantics is used.

While the _InterlockedExchange function operates on 32-bit integer values, _InterlockedExchange64 operates on 64-bit integer values.

The _InterlockedExchange_acq and _InterlockedExchange64_acq intrinsic functions are the same as the corresponding functions without the _acq suffix except that the operation is performed with acquire semantics, which is useful when entering a critical section.

There is no version of this function that uses release semantics.

In Visual C++ 2005, these functions behave as read-write memory barriers. For more information, see _ReadWriteBarrier.

These routines are only available as intrinsics.

For a sample of how to use _InterlockedExchange, see _InterlockedDecrement.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker