// wdm.h
BOOLEAN ExAcquireSharedWaitForExclusive(
[in, out] PERESOURCE Resource,
[in] BOOLEAN Wait
);
View the official Windows Driver Kit DDI reference
No description available.
The ExAcquireSharedWaitForExclusive routine acquires the given resource for shared access if shared access can be granted and there are no exclusive waiters.
Resource
[in, out]A pointer to the resource to be acquired for shared access.
Wait
[in]Specifies the routine's behavior whenever the resource cannot be acquired immediately. If TRUE, the caller is put into a wait state until the resource can be acquired. If FALSE, the routine immediately returns, regardless of whether the resource can be acquired.
ExAcquireSharedWaitForExclusive returns TRUE if the requested access is granted or an exclusive owner releases the resource. This routine returns FALSE if the input Wait is FALSE and shared access cannot be granted immediately.
Most drivers should use ExAcquireResourceSharedLite instead of ExAcquireSharedWaitForExclusive.
The caller can release the resource by calling either ExReleaseResourceLite or ExReleaseResourceForThreadLite.
If shared access cannot be granted immediately, the caller can wait for other threads to acquire and release exclusive ownership of the resource.
Whether or when the caller is given shared access to the given resource depends on the following:
If the resource is currently owned as shared but there is a pending attempt to acquire exclusive access, the caller either is put into a wait state (Wait set to TRUE) or ExAcquireSharedWaitForExclusive returns FALSE.
When the current thread waits to acquire the resource until after a pending exclusive ownership has been released, ExAcquireSharedWaitForExclusive returns TRUE when the current thread is granted shared access to the resource and resumes execution.
The behavior of ExAcquireSharedWaitForExclusive is identical to that of ExAcquireResourceSharedLite unless the calling thread already owns the resource as shared and there are exclusive waiters. In that case, ExAcquireSharedWaitForExclusive allows the exclusive waiters to acquire exclusive ownership of the resource.
If the caller specifies TRUE for the Wait parameter, the caller blocks until another thread frees the resource on behalf of the caller, using ExReleaseResourceForThread. Driver writers must be careful to ensure that another thread actually releases the resource; otherwise the caller is deadlocked. ExAcquireResourceSharedLite does not have this property, so drivers should use that routine unless they require the particular behavior of ExAcquireSharedWaitForExclusive.
Normal kernel APC delivery must be disabled before calling this routine. Disable normal kernel APC delivery by calling KeEnterCriticalRegion. Delivery must remain disabled until the resource is released, at which point it can be reenabled by calling KeLeaveCriticalRegion. For more information, see Disabling APCs.
ExAcquireSharedStarveExclusive
ExConvertExclusiveToSharedLite
ExIsResourceAcquiredExclusiveLite
ExIsResourceAcquiredSharedLite