3.2.6 Synchronization During Initialization

When a miniport initializes its NIC, it might need to wait for a state change before continuing execution. NDIS provide two mechanisms that can be used.

MiniportInitialize can call NdisMSleep to delay execution for a specified interval expressed in microseconds. When MiniportInitialize calls NdisMSleep, it is put into a suspended state. When the sleep interval expires, MiniportInitialize resumes execution. MiniportInitialize should not call NdisStallExecution, a function that is only called at raised IRQL and only for intervals less than 50 microseconds.

MiniportInitialize can also synchronize with events. MiniportInitialize can create an event by calling NdisInitializeEvent. Then after MiniportInitialize writes to its NIC, it calls NdisWaitEvent. When an interrupt occurs and MiniportHandleInterrupt runs, it clears the interrupt on the NIC and sets the event by calling NdisSetEvent. MiniportInitialize, which was waiting on the event, now has its wait satisfied, so it clears the event by calling NdisResetEvent and continues with its execution.