ExAcquireSharedStarveExclusive
BOOLEAN
ExAcquireSharedStarveExclusive(
IN PERESOURCE Resource,
IN BOOLEAN Wait
);
ExAcquireSharedStarveExclusive acquires a given resource for shared access without waiting for any pending attempts to acquire exclusive access to the same 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
ExAcquireSharedStarveExclusive returns TRUE if the requested access is granted. 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 acquired the resource, the current thread is granted the same type of access recursively. Note that making this call does not convert a caller's exclusive ownership of a given resource to shared.
·If the resource is currently owned as shared by another thread, shared access is granted to the caller immediately, even if another thread is waiting for exclusive access to that resource.
·If the resource is currently owned as exclusive by another thread, the caller either is put into a wait state (Wait set to TRUE) or ExAcquireSharedStarveExclusive returns FALSE.
Callers of ExAcquireSharedStarveExclusive usually need quick access to a shared resource in order to save an exclusive accessor from doing redundant work. For example, a file system might call this routine to modify a cached resource, such as a BCB pinned in the cache, before the Cache Manager can acquire exclusive access to the resource and write the cache out to disk.
Callers of ExAcquireSharedStarveExclusive must be running at IRQL < DISPATCH_LEVEL.
See Also
ExAcquireResourceSharedLite, ExAcquireSharedWaitForExclusive, ExConvertExclusiveToSharedLite, ExGetExclusiveWaiterCount, ExIsResourceAcquiredExclusiveLite, ExIsResourceAcquiredSharedLite, ExTryToAcquireResourceExclusiveLite