2.2 Multiprocessor Support

Writing code to safely run on machines with more than one, concurrently executing processors is an essential part of writing a portable Windows NT driver. A network driver must be multiprocessor-safe, as well as use the provided NDIS library functions.

A major advantage of miniport NIC drivers over the legacy, full-NIC drivers is that the NDIS library functions for miniports handle many of these multiprocessor considerations. The NDIS library queues requests so the miniport NIC driver need not contain code for this. In contrast, the driver developer of a full-NIC driver must have the necessary functions and protections 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 NIC or other device to interrupt the current execution stream when packets arrive or as timer interrupts occur. Typically, when manipulating data structures such as packet queues, a driver disables interrupts on the NIC, performs the manipulation, and then re-enables interrupts. Many threads in a uniprocessor environment appear to run simultaneously but actually run in interleaved time slices.

In a multiprocessor environment, processors simultaneously run several machine instructions. A driver must synchronize so that when one driver function manipulates common data structures, the same or another driver function on another processor does not attempt to modify shared data at the same time. All driver code is re-entrant in an SMP machine. To eliminate this resource protection problem, Windows NT device drivers use spin locks.