3.2 Multiprocessor Support

The support of multiple, concurrently executing processors is an essential part of a portable Windows NT driver. A network driver should be multiprocessor-safe and use the provided NDIS interface library or wrapper functions.

A major advantage of miniport NIC drivers over the older-style full NIC drivers is that the NDIS interface library functions for miniports handle these multiprocessor considerations. The NDIS library queues requests from multiple processors so the miniport NIC driver need not contain code for this. In contrast, the device driver writer must code in the necessary functions and protections for full NIC drivers to make the network driver multiprocessor-safe.

In a uniprocessor environment, a single processor runs only one machine instruction at a time even though it is possible for a network interface card to interrupt the current execution stream when packets arrive or as timer interrupts occur. Typically, when manipulating data structures such as packet queues, you would disable the interrupts on the processor, perform the manipulation, and then re-enable the interrupts. Multiple threads in a uniprocessor environment appear to run simultaneously but actually run in interleaved time slices.

In a multiprocessor environment, multiple processors simultaneously run multiple machine instructions. It is important to synchronize the processors so that when your driver manipulates common data structures, the processors do not attempt to modify them at the same time. Disabling interrupts on the processor running the modification code does not stop the other processors from executing the same code path. To alleviate this resource protection problem, Windows NT device drivers use spin locks. For more information about spin locks, see Section 3.3.