Chapter 4 -- Synchronization

[Previous] [Next]

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:

  • The operating system can preempt any subroutine at any moment for an arbitrarily long period of time, so we cannot be sure of completing critical tasks without interference or delay.
  • Even if we take steps to prevent preemption, code executing simultaneously on another CPU in the same computer can interfere with our code—it's even possible that the exact same set of instructions belonging to one of our programs could be executing in parallel in the context of two different threads.

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.



Programming the Microsoft Windows Driver Model
Programming the Microsoft Windows Driver Model
ISBN: 0735618038
EAN: 2147483647
Year: 1999
Pages: 93
Authors: Walter Oney

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net