Chapter 4: Synchronization

Chapter 4

Synchronization

Microsoft Windows XP 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 XP; one good place to get more information is David Solomon and Mark Russinovich s Inside Windows 2000, Third Edition (Microsoft Press, 2000). 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 same set of instructions belonging to one of our programs could be executing in parallel in the context of two different threads.

Windows XP allows you to solve these general synchronization problems by using a variety of synchronization primitives. The system prioritizes the handling of hardware and software interrupts with the interrupt request level (IRQL). The system offers a variety of synchronization primitives. Some of these primitives are appropriate at times when you can safely block and unblock threads. One primitive, the spin lock, allows you to synchronize access to shared resources even at times when thread blocking wouldn t be allowed because of the priority level at which a program runs.



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

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