The InterlockedCompareExchangeToUser function performs an atomic compare-and-exchange operation on a 32-bit value in user-mode memory.
Syntax
LONG InterlockedCompareExchangeToUser(
LONG volatile *Destination,
LONG ExChange,
LONG Comperand
);
Parameters
Destination
[in, out] 대상 값을 포함하는 사용자 모드 메모리 위치에 대한 포인터입니다. The pointer must be naturally aligned for the data type; that is, the memory location must be 4-byte aligned since Destination points to a 4-byte type.
ExChange
[in] 교환 값입니다.
Comperand
[in] The value to compare to Destination.
Return value
The function returns the initial value of the Destination parameter.
Remarks
연동 함수는 여러 스레드에서 공유하는 변수에 대한 액세스를 동기화하는 간단한 메커니즘을 제공합니다. 이 함수는 다른 연동 함수에 대한 호출과 관련하여 원자성입니다. 메모리 작업이 순서대로 완료되도록 전체 메모리 장벽을 생성합니다.
이 함수는 사용자 모드 메모리의 32비트 값에 대한 원자성 비교 및 교환 액세스를 제공합니다. The function compares the Destination value with the Comperand value. If the Destination value is equal to the Comperand value, the ExChange value is stored in the address specified by Destination. 그렇지 않으면 작업이 수행되지 않습니다.
이 함수는 대상 주소가 유효한 사용자 모드 주소가 아니거나 액세스할 수 없는 경우와 같이 작업이 실패할 경우 구조적 예외를 발생합니다.
이 함수는 최신 버전뿐만 아니라 모든 버전의 Windows에서 작동합니다. You need to consume the latest WDK to get the function declaration from the usermode_accessors.h header. You also need the library (umaccess.lib) from the latest WDK. 그러나 결과 드라이버는 이전 버전의 Windows에서 잘 실행됩니다.
Requirements
| Requirement | Value |
|---|---|
| 지원되는 최소 클라이언트 | See Remarks |
| Header | usermode_accessors.h |
| Library | umaccess.lib |
| IRQL | APC_LEVEL 작거나 같음 |