Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
This function performs an atomic comparison of the specified values and exchanges the values based on the outcome of the comparison. The function prevents more than one thread from using the same variable simultaneously.
Syntax
LONG InterlockedCompareExchange( LPLONG Destination, LONG Exchange, LONG Comperand ); |
Parameters
- Destination
-
[in, out] Specifies the address of the destination value. The sign is ignored.
- Exchange
-
[in] Specifies the exchange value. The sign is ignored.
- Comperand
-
[in] Specifies the value to compare to Destination. The sign is ignored.
Return Value
Initial value of the destination.
Remarks
The InterlockedCompareExchange, InterlockedDecrement, InterlockedExchange, InterlockedExchangeAdd, and InterlockedIncrementfunctions provide a simple mechanism for synchronizing access to a variable that is shared by multiple threads. The threads of different processes can use this mechanism if the variable is in shared memory.
The InterlockedCompareExchangefunction performs an atomic comparison of the Destinationvalue with the Comperandvalue. If the Destinationvalue is equal to the Comperandvalue, the Exchangevalue is stored in the address specified by Destination. Otherwise, no operation is performed.
The variables for InterlockedCompareExchangemust be aligned on a 32-bit boundary.
Each object type, such as memory maps, semaphores, events, message queues, mutexes, and watchdog timers, has its own separate namespace. Empty strings ("") are handled as named objects. On Windows desktop-based platforms, synchronization objects all share the same namespace.
Requirements
Header | windows.h |
Library | coredll.lib |
Windows Embedded CE | Windows CE .NET 4.0 and later |
Windows Mobile | Windows Mobile Version 5.0 and later |
See Also
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at webmaster@systemmanager.forsenergy.ru to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.