Partager via


NdisAcquireReadWriteLock (Windows Embedded CE 6.0)

1/6/2010

This function acquires a lock that the caller uses for either write or read access to the resources that are shared among driver threads.

Syntax

VOID NdisAcquireReadWriteLock(
  PNDIS_RW_LOCK Lock,
  BOOLEAN fWrite,
  PLOCK_STATE LockState
);

Parameters

  • Lock
    [in] Points to an opaque variable that represents a lock. The caller can use this lock to access shared resources.
  • fWrite
    [in] Specifies a Boolean value. If the value is TRUE, this function is provided with write access to shared resources. If the value is FALSE, this function is provided with read access.
  • LockState
    [in] Points to an opaque variable that tracks the state of the lock. This variable exists in the interval between the time the caller acquires and releases the lock. The caller must use a different variable of type LOCK_STATE for each attempt it makes to acquire the lock from the same non-ISR driver thread.

Return Value

None.

Remarks

The driver must initialize a variable of type NDIS_RW_LOCK using NdisInitializeReadWriteLock before the driver calls any other NdisXXXReadWriteLock function. The driver must provide resident storage for the locks it uses.

After acquiring a lock by using NdisAcquireReadWriteLock, the caller must release that lock by calling NdisReleaseReadWriteLock. To decrement the reference count of the lock, a driver must call NdisReleaseReadWriteLock once for each call to NdisAcquireReadWriteLock.

To modify resources shared among driver threads, a driver thread must acquire a write lock. To simply monitor those resources, a driver thread must acquire a read-only lock. Read access does not require interlocked operations or contention for spin locks. Using read-only access helps to maintain good operating system and driver performance.

A driver thread should never hold a write lock for more than 25 microseconds. Holding a write lock for a prolonged period degrades both operating system and driver performance.

Requirements

Header ndis.h
Library ndis.lib
Windows Embedded CE Windows CE .NET 4.0 and later

See Also

Reference

NDIS Library Functions
NdisInitializeReadWriteLock
NdisMSynchronizeWithInterrupt
NdisReleaseReadWriteLock