Synchronizing Driver Activities

The kernel-mode audio drivers, including the Sound Blaster driver, do not provide a StartIo function, so they must manage their own queues of I/O Request Packets (IRPs). You must consider synchronization issues under the following circumstances:

·Opening and closing devices.

·Handling I/O requests, which are sent when a client calls ReadFile, WriteFile, or DeviceIoControl, and which are received in IRPs.

·Sharing hardware. For instance, MIDI input and output hardware sometimes uses the same I/O ports as waveform input and output hardware.

·Synchronizing with Deferred Procedure Call routines (DPCs).

·Synchronizing with Interrupt Service Routines (ISRs).

Most of the time, kernel-mode audio drivers execute at PASSIVE_LEVEL priority. Synchronization can be achieved by:

·Using exclusion routines

·Using spin locks

·Using KeSynchronizeExecution

·Using system worker threads