5 Synchronization Questions - UNDER CONSTRUCTION

5.1 What synchronization problems apply to kernel mode drivers?

  • Most driver routines can be interrupted at any time, possibly by the driver's own interrupt service routine (ISR).
  • On a multiprocessor system, various instances of certain types of driver routines might be executing at literally the same time on behalf of the same device.
  • In most drivers, several instances of the driver's dispatch routine(s) might be active at the same time for the same device, even on single-processor systems.

There are uncommon scenarios in which there are other issues, but these cover most of the standard cases.

5.2 Can't we just use a mutex like we do from Win32?

Well, there are certain routines in certain drivers that can, but in general, no. If you request it but can't acquire it right away, your thread waits for the mutex to become signalled. Most driver routines either always, or may sometimes, be called from contexts where they can't enter a wait.

5.3 So, what do we do instead of using a mutex?

Usually you associate a spinlock with the data or other resources that your various routine instances are trying to access.


top of page | up | previous | next | home