Search code examples
windowsmultithreadingkernelwdk

Spawning a kernel mode thread - Windows


I have intensive processing that I need to perform in a device driver, at DISPATCH_LEVEL or lower IRQL.

  • How do I create a kernel-thread?
  • What IRQL does it run at? Can I control this?
  • How is it scheduled? Because I am thinking from a user-mode perspective here, what priority does it run at?
  • What kernel functions can I use to provide locking / synchronization?

Solution

  • you can create system thread with this As you can see one of its parameters is a start routine which can hold custom code - in it you can use KeRaiseIrql and KeLowerIrql. By default threads will run in PASSIVE_LEVEL. "Locks, Deadlocks, and Synchronization" is a very helpful paper regarding synchronization in kernel on windows and everyone who has to do some tinkering with the windows kernel should read or at least skim it