Chapter 4
Microsoft Windows 2000 is a multitasking operating system that can run in a symmetric multiprocessor environment. It's not my purpose here to provide a rigorous description of the multitasking capabilities of Microsoft Windows NT; one good place to get more information is David Solomon's Inside Windows NT, Second Edition (Microsoft Press, 1998). All we need to understand as driver writers is that our code executes in the context of one thread or another (and the thread context can change from one invocation of our code to another) and that the exigencies of multitasking can yank control away from us at practically any moment. Furthermore, true simultaneous execution of multiple threads is possible on a multiprocessor machine. In general, we need to assume two worst-case scenarios:
Windows NT allows you to solve these general synchronization problems by using the interrupt request level (IRQL) priority scheme and by claiming and releasing spin locks around critical code sections. IRQL avoids destructive preemption on a single CPU, while spin locks forestall interference among CPUs.