ExAcquireSharedWaitForExclusive

BOOLEAN
ExAcquireSharedWaitForExclusive(

IN PERESOURCE Resource,
IN BOOLEAN Wait
);

ExAcquireSharedWaitForExclusive acquires the given resource for shared access immediately if shared access can be granted. Optionally, the caller can wait for other thread(s) to acquire and release exclusive ownership of the resource.

Parameters

Resource

Points to the resource to be acquired for shared access.

Wait

Is set to TRUE if the caller will wait until the resource becomes available when access cannot be granted immediately.

Return Value

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.

Comments

Whether or when the caller is given shared access to the given resource depends on the following:

·If the resource is currently unowned, shared access is granted immediately to the current thread.

·If the caller already has exclusive access to the resource, the current thread is granted the same type of access recursively.

·If the resource is currently owned as shared and there are no pending attempts to acquire exclusive access, shared access is granted to the caller immediately.

·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.

Callers of ExAcquireSharedWaitForExclusive must be running at IRQL < DISPATCH_LEVEL.

See Also

ExAcquireResourceSharedLite, ExAcquireSharedStarveExclusive, ExConvertExclusiveToSharedLite, ExGetExclusiveWaiterCount, ExIsResourceAcquiredExclusiveLite, ExIsResourceAcquiredSharedLite, ExTryToAcquireResourceExclusiveLite