次の方法で共有


ExAcquireResourceExclusiveLite routine

The ExAcquireResourceExclusiveLite routine acquires the given resource for exclusive access by the calling thread.

Syntax

BOOLEAN ExAcquireResourceExclusiveLite(
  _Inout_ PERESOURCE Resource,
  _In_    BOOLEAN    Wait
);

Parameters

  • Resource [in, out]
    A pointer to the resource to acquire.

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

Return value

ExAcquireResourceExclusiveLite returns TRUE if the resource is acquired. This routine returns FALSE if the input Wait is FALSE and exclusive access cannot be granted immediately.

Remarks

The following list describes whether and when a caller is given exclusive access to a given resource:

  • If the resource is currently not owned, exclusive access is granted immediately to the current thread.

  • If the caller already had acquired the resource for exclusive access, the current thread is granted the same type of access recursively.

  • If the caller has shared access to the resource, the caller must release the lock before it attempts to reacquire it exclusively.

  • If the resource is currently owned as exclusive by another thread, or if the caller only has shared access to the resource, the current thread is put into a wait state until the resource can be acquired.

Note   If two threads each hold a shared lock on the same resource and both attempt to acquire the lock exclusively without releasing their shared lock, they will deadlock. This means that each thread will wait for the other to release its shared hold on the lock, and neither will release its shared hold until the other does.

 

The caller can release the resource by calling either ExReleaseResourceLite or ExReleaseResourceForThreadLite.

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.

Requirements

Target platform

Universal

Version

Available starting with Windows 2000.

Header

Wdm.h (include Wdm.h, Ntddk.h, or Ntifs.h)

Library

NtosKrnl.lib

DLL

NtosKrnl.exe

IRQL

<= APC_LEVEL

DDI compliance rules

ExclusiveResourceAccess, IrqlExApcLte3, WithinCriticalRegion, HwStorPortProhibitedDDIs, WithinCriticalRegion(storport)

See also

ExAcquireResourceSharedLite

ExGetExclusiveWaiterCount

ExGetSharedWaiterCount

ExInitializeResourceLite

ExReinitializeResourceLite

ExIsResourceAcquiredExclusiveLite

ExReleaseResourceForThreadLite

KeEnterCriticalRegion

 

 

Send comments about this topic to Microsoft