NdisInitializeReadWriteLock

This function initializes a variable of type NDIS_RW_LOCK. An NDIS_RW_LOCK variable is used to limit write access to shared resources to one non-ISR driver thread at a time. This NDIS_RW_LOCK can allow multiple non-ISR driver threads concurrent read access to those resources. Such read access is not permitted during a write access.

VOID NdisInitializeReadWriteLock(
  PNDIS_RW_LOCK Lock
);

Parameters

  • Lock
    [in] Points to an opaque variable that represents a lock. The caller can use this lock to gain write or read access to resources that are shared among non-ISR driver threads.

Return Values

None.

Remarks

The Lock pointer that is passed to NdisInitializeReadWriteLock is a required parameter for all other NdisXXXReadWriteLock functions.

Before a driver calls NdisAcquireReadWriteLock to obtain write or read access to a resource, the driver must call NdisInitializeReadWriteLock to initialize the lock that is associated with that resource. The caller must provide storage for the variable at Lock.

After calling NdisInitializeReadWriteLock, the driver can call NdisAcquireReadWriteLock to obtain either write or read access to the resource. Only one non-ISR driver thread at a time can obtain write access to the resource. When one non-ISR thread has write access, all read and write accesses by other non-ISR threads must wait until the write-access holder releases the lock. However, if a non-ISR thread has read access, other non-ISR threads can concurrently acquire read access.

Initialize and use this type of lock for resources that are frequently accessed for reading and infrequently accessed for writing.

Once resource access is complete, the driver calls NdisReleaseReadWriteLock.

Requirements

OS Versions: Windows CE .NET 4.0 and later.
Header: Ndis.h.

See Also

NdisAcquireReadWriteLock | NdisReleaseReadWriteLock | NdisFreeReadWriteLock

 Last updated on Tuesday, May 18, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.