Ray Of Hope

IRQL- Interrupt Request Level

An interrupt request level (IRQL) defines the hardware priority at which a processor operates at any given time. In the Windows Driver Model, a thread running at a low IRQL can be interrupted to run code at a higher IRQL.

X-86 based system has 32 IRQL.

IRQL                                   X86                        Ia64                         AMD64                                      Description

Passive Level               o                                 o                                o                         User Thread and most kernel mode operations

APC Level                       1                                 1                               1                         Asynchronous procedure calls and page faults

Dispatch Level              2                                2                              2                      Thread scheduler and deferred procedure calls

CMC_Level                   N/A                           3                             N/A                 Correctable machine check level

and other level. Can be easily fetched from internet.

When a processor is running at a give IRQL , interrupts at that IRQL and lowwe are masked off (blocked) on the processor. For example, a processor that is running at IRQL = DISPATCH_LEVEL can be interrupted only by a request at an IRQL greater thatn DISPATCH_LEVEL.


The system scehdules all threads to run at IRQLs below DISPATCH_LEVEL and the system’s thread scheduler itself (also called “the dispatcher”) runs at IRQL= DISPATCH_LEVEL. Consequently , a thread that is running at or above DISPATCH_LEVEL has, in effect, exclusive use of the current processor.  Because DISPATCH_LEVEL interrupts are masked off on the processor, the thread scheduler cannot run on that processor and thus cannot schedule any thread.

On a multiprocessor system, each processor can be running at a different IRQL. Therefore , one processor could run a driver’s InterruptService routine at DIRQL while a second processor runs driver code in worker thread at PASSIVE_LEVEL. Because more than one thread could thus attempt to access shared data simultaneously, drivers must protect shared data by using an appropriate synchronization method. Drivers should use a lock that raises the IRQL to the highest level at which any code that accesses the data can run. For eg. , a driver uses a spin lock to protect data that can be accessed at IRQL= DISPATCH_LEVEL.

On a single processor system , raising IRQL to DISPATCH_LEVEL or higher has the same effect as using a spin lock because raising the IRQL can prevent the pre-emption or interruption of the currently executing code. For eg. , when a driver’s StartIO routine is running at DISPATCH_LEVEL on a single processor system, other driver code that runs at APC_LEVEL or PASSIVE_LEVEL cannot run until the IRQL drops. Similarly, when a driver’w InterruptService routine routine is running at DIRQL, the DPC queued by that routine cannot run until the InteruptService routine exists. In fact, the operation system’s spin lock acquisition and release routines raise the IRQL on single-processor systems.

The thread scheduler considers only thread priority, and not IRQL, when preempting a thread. If a thread running at IRQL=APC_LEVEL blocks, the scheduler might select a new thread for the processor that was previously running at PASSIVE_LEVEL.

Originally Posted On: 2010-04-17 02:40:56

Anshul Makkar


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.