2.3.2.6  Synchronization Functions

The following table defines the synchronization functions included in the NDIS library for miniport drivers.

The timer functions allow the miniport to implement an operation that occurs at a driver-requested interval. For instance, a driver can use a timer to poll its NIC. Events can be used to synchronize operations between two threads, at least one running at IRQL PASSIVE_LEVEL. Spin locks are used to synchronize access to shared resources, as is the NdisMSynchronizeWithInterrupt function.

Function Definition
NdisMCancelTimer Cancels a timer that was previously set with NdisMSetTimer.
NdisMInitializeTimer Initializes a timer object and associates a MiniportTimer function with the object.
NdisMSetTimer Sets a timer to go off after a specified interval.
NdisMSetPeriodicTimer Sets a timer that goes off automatically at a specified interval of until cancelled with a call to NdisMCancelTimer.
NdisSleep Causes the caller’s thread  to block for the specified interval. A driver calls NdisSleep during initialization or when halting the adapter, for instance, while waiting for the NIC to complete initialization. NdisSleep is only called at IRQL PASSIVE_LEVEL.
NdisStallExecution Causes the caller’s thread to stall for a specified interval not to exceed 50 milliseconds. NdisStallExecution is only called at raised IRQL when NdisSleep cannot be used.
NdisInitializeEvent Creates and initializes an event which can then be used to synchronize driver operations.
NdisSetEvent Signals the specified event.
NdisResetEvent Resets the specified event to the unsignaled state.
NdisWaitEvent Causes the caller to wait until the specified event is signaled or the specified time interval expires.
NdisAcquireSpinLock Acquires a spin lock to protect access to shared resources between nonISR driver functions in an SMP-safe way.  Miniports that are running at IRQL < DISPATCH_LEVEL call this function to acquire a spin lock.
NdisReleaseSpinLock Releases a spin lock previously acquired by calling NdisAcquireSpinLock.
NdisDprAcquireSpinLock Acquires a spin lock at IRQL DISPATCH_LEVEL. Protects access to shared resources between nonISR driver functions in an SMP-safe way. Faster than calling NdisAcquireSpinLock for driver functions running at IRQL DISPATCH_LEVEL.
NdisDprReleaseSpinLock Releases a spin lock previously acquired by calling NdisDprAcquireSpinLock.
NdisMSynchronizeWithInterrupt Any NIC driver function that shares resources with the MiniportISR or MiniportDisableInterrupt functions must synchronize access to the resources with these two functions to prevent race conditions. Such functions that must synchronize with MiniportISR and MiniportDisableInterrupt do so by calling NdisMSynchronizeWithInterrupt with a MiniportSynchronizeISR function that also runs at DIRQL while it accesses the shared resource.