AcquireSRWLockExclusive
AcquireSRWLockExclusive acquires the SRW lock in exclusive mode. Only one thread can hold the lock in exclusive mode at a time. If the lock is already held (in either shared or exclusive mode), the calling thread blocks until the lock can be acquired.
Syntax
VOID AcquireSRWLockExclusive(
PSRWLOCK pSrwLock
);
Parameters
pSrwLock
A pointer to the SRW lock to acquire.
Return Value
This function does not return a value.
Remarks
- This function blocks the calling thread until the lock can be acquired exclusively
- The lock cannot be acquired while any thread holds the lock in shared or exclusive mode.
- This function uses spin-waiting with yielding for contended scenarios
- This function raises EXCEPTION_ACCESS_VIOLATION if pSrwLock is NULL
Requirements
| Minimum supported version | Header | Library |
|---|---|---|
|
wRTOS 1.1 SDK |
windows.h |
wRTOS_rtss.lib |
Example
SRWLOCK lock;
InitializeSRWLock(&lock);
AcquireSRWLockExclusive(&lock);
// Perform exclusive write operations
ReleaseSRWLockExclusive(&lock);
See Also: