IRQ Levels in windows OS

Hi All,

I have a question about IRQ Levels in windows. Why windows need them? Also I would like to learn fundamentals of it.

Also I want to learn how is it related to paged pool memory & non paged pool memory.

Any suggestions?

Thanks,
Harsha


Yahoo! Shopping
Find Great Deals on Holiday Gifts at Yahoo! Shopping

You should pick up solomon and russinovitch’s inside windows book (whatever the newest edition is). It explains IRQL very well.

As how it is related to paged memory, this is how (glossing over some details). When a page fault occurs, the memory subsystem will raise to dispatch level and bring in the page and then let the thread continue. If you are already at dispatch level when the page fault occurs, the memory subsystem cannot run since the OS is already running at that IRQL (which is basically a deadlock), the page fault cannot be handled and you have an unhandled exception on the fault (which causes a bluescreen of death)

d


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Harsha Inamdar
Sent: Tuesday, December 13, 2005 6:56 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] IRQ Levels in windows OS

Hi All,
?
I have a question about IRQ Levels in windows. Why windows need them? Also I would like to learn fundamentals of it.
?
Also I want to learn how is it related to paged pool memory & non paged pool memory.
?
Any suggestions?
?
Thanks,
Harsha


Yahoo! Shopping
Find Great Deals on Holiday Gifts at Yahoo! Shopping — Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256 You are currently subscribed to ntdev as: xxxxx@microsoft.com To unsubscribe send a blank email to xxxxx@lists.osr.com

The concept is very simple, the details are hairy. I’m giving you a simple-minded version of it, some of the people in this list may object to some of it, but hey, works for me!

You basically have two IRQ spaces: interrupt and non-interrupt. You’re more often than not in what’s called “Passive” level, which means, you’re not in an interrupt routine, and hence, much of the kernel-side Operating System API is available to you. When a task is running at Passive Level it is preemptable according to the rules of the OS, and so on.

When an interrupt occurs, you’re in an “Interrupt” level, and you’re now in Interrupt Space. The IRQ levels are assigned in a kind of a hierarchical base, and the rule is that a peripheral’s Interrupt Service Routine can only be preempted by another higher-priority interrupt, meaning that the interrupting source (or peripheral) has a higher IRQ Level than the Level your ISR is currently running. So, “important” peripherals have a higher IRQ Level and they can interrupt “less important” peripherals whose ISRs run at lower IRQ Level.

Note that once you leave passive level, the normal rules of thread and process switching no longer apply. Windows has a couple of what I call “intermediate” levels, between Passive and Interrupt levels, the APC (Asynchronous Procedure Call) and DPC (Dispatch) levels. These are reserved for drivers and other OS functionality that must run without OS preemption but that aren’t as important as an interrupt service routine.

Now, you will understand that if you’re in an Interrupt IRQ Level, it may be the case that not all the OS’s API is available to you. Many OS kernel-side calls are not allowed if you’re running at an Interrupt IRQ Level. The issue with the memory pools is that you do not want to have a page fault to happen inside an Interrupt Service Routine, or maybe even at APC or DPC level: hence, you may not want to use non-paged pool memory when you’re at an Interrupt IRQ Level, because if that memory is paged out you will get a page fault interrupt and that throws a monkey wrench in the workings of the OS!

Now, this idea is as old as computing, and in the past IRQ Levels were handled almost one hundred per cent by the hardware. With Windows the design has spilled into the software, and you must be aware of it, specially when it comes to what kind of memory you’re using and what API calls you make to the OS. And as I said, there’s a wealth of detail behind this, so, take a look at Russinovitch and Solomon’s book, or read the DDK documentation carefully if you need more information.

Hope this helps,

Alberto.

----- Original Message -----
From: Harsha Inamdar
To: Windows System Software Devs Interest List
Sent: Tuesday, December 13, 2005 9:56 PM
Subject: [ntdev] IRQ Levels in windows OS

Hi All,

I have a question about IRQ Levels in windows. Why windows need them? Also I would like to learn fundamentals of it.

Also I want to learn how is it related to paged pool memory & non paged pool memory.

Any suggestions?

Thanks,
Harsha


Yahoo! Shopping
Find Great Deals on Holiday Gifts at Yahoo! Shopping — Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256 You are currently subscribed to ntdev as: xxxxx@ieee.org To unsubscribe send a blank email to xxxxx@lists.osr.com

Thank you very much for your reply. I have solomon and russinovitch’s inside windows book. It has a sentence as “Although interrupt controllers perform a level of interrupt prioritization, windows imposes its own interrupt priority scheme known as IRQL.”

Now my question is why does windows need it? What are the advantages over interrupt controllers?

Thanks,
Harsha

Doron Holan wrote:
You should pick up solomon and russinovitch’s inside windows book (whatever the newest edition is). It explains IRQL very well.

As how it is related to paged memory, this is how (glossing over some details). When a page fault occurs, the memory subsystem will raise to dispatch level and bring in the page and then let the thread continue. If you are already at dispatch level when the page fault occurs, the memory subsystem cannot run since the OS is already running at that IRQL (which is basically a deadlock), the page fault cannot be handled and you have an unhandled exception on the fault (which causes a bluescreen of death)

d

From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Harsha Inamdar
Sent: Tuesday, December 13, 2005 6:56 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] IRQ Levels in windows OS

Hi All,

I have a question about IRQ Levels in windows. Why windows need them? Also I would like to learn fundamentals of it.

Also I want to learn how is it related to paged pool memory & non paged pool memory.

Any suggestions?

Thanks,
Harsha

Yahoo! Shopping
Find Great Deals on Holiday Gifts at Yahoo! Shopping — Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256 You are currently subscribed to ntdev as: xxxxx@microsoft.com To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

---------------------------------
Yahoo! Shopping
Find Great Deals on Holiday Gifts at Yahoo! Shopping

Thank you very much for detailed reply.

Alberto Moreira wrote: The concept is very simple, the details are hairy. I’m giving you a simple-minded version of it, some of the people in this list may object to some of it, but hey, works for me!

You basically have two IRQ spaces: interrupt and non-interrupt. You’re more often than not in what’s called “Passive” level, which means, you’re not in an interrupt routine, and hence, much of the kernel-side Operating System API is available to you. When a task is running at Passive Level it is preemptable according to the rules of the OS, and so on.

When an interrupt occurs, you’re in an “Interrupt” level, and you’re now in Interrupt Space. The IRQ levels are assigned in a kind of a hierarchical base, and the rule is that a peripheral’s Interrupt Service Routine can only be preempted by another higher-priority interrupt, meaning that the interrupting source (or peripheral) has a higher IRQ Level than the Level your ISR is currently running. So, “important” peripherals have a higher IRQ Level and they can interrupt “less important” peripherals whose ISRs run at lower IRQ Level.

Note that once you leave passive level, the normal rules of thread and process switching no longer apply. Windows has a couple of what I call “intermediate” levels, between Passive and Interrupt levels, the APC (Asynchronous Procedure Call) and DPC (Dispatch) levels. These are reserved for drivers and other OS functionality that must run without OS preemption but that aren’t as important as an interrupt service routine.

Now, you will understand that if you’re in an Interrupt IRQ Level, it may be the case that not all the OS’s API is available to you. Many OS kernel-side calls are not allowed if you’re running at an Interrupt IRQ Level. The issue with the memory pools is that you do not want to have a page fault to happen inside an Interrupt Service Routine, or maybe even at APC or DPC level: hence, you may not want to use non-paged pool memory when you’re at an Interrupt IRQ Level, because if that memory is paged out you will get a page fault interrupt and that throws a monkey wrench in the workings of the OS!

Now, this idea is as old as computing, and in the past IRQ Levels were handled almost one hundred per cent by the hardware. With Windows the design has spilled into the software, and you must be aware of it, specially when it comes to what kind of memory you’re using and what API calls you make to the OS. And as I said, there’s a wealth of detail behind this, so, take a look at Russinovitch and Solomon’s book, or read the DDK documentation carefully if you need more information.

Hope this helps,

Alberto.

----- Original Message -----
From: Harsha Inamdar
To: Windows System Software Devs Interest List
Sent: Tuesday, December 13, 2005 9:56 PM
Subject: [ntdev] IRQ Levels in windows OS

Hi All,

I have a question about IRQ Levels in windows. Why windows need them? Also I would like to learn fundamentals of it.

Also I want to learn how is it related to paged pool memory & non paged pool memory.

Any suggestions?

Thanks,
Harsha

---------------------------------
Yahoo! Shopping
Find Great Deals on Holiday Gifts at Yahoo! Shopping — Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256 You are currently subscribed to ntdev as: xxxxx@ieee.org To unsubscribe send a blank email to xxxxx@lists.osr.com

Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

---------------------------------
Yahoo! Shopping
Find Great Deals on Holiday Gifts at Yahoo! Shopping

I’m sure that Doron was well-meaning in his response. (I’ll ask him, as I’m
about to have lunch with him.) But that’s not much of an explanation.
Please start here:

http://www.microsoft.com/whdc/driver/kernel/IRQL.mspx


Jake Oshins
Windows Kernel Group

The Virtual Machine Team at Microsoft is hiring. Contact
xxxxx@microsoft.com for more information.

This posting is provided “AS IS” with no warranties, and confers no rights.

“Doron Holan” wrote in message
news:xxxxx@ntdev…
You should pick up solomon and russinovitch’s inside windows book (whatever
the newest edition is). It explains IRQL very well.

As how it is related to paged memory, this is how (glossing over some
details). When a page fault occurs, the memory subsystem will raise to
dispatch level and bring in the page and then let the thread continue. If
you are already at dispatch level when the page fault occurs, the memory
subsystem cannot run since the OS is already running at that IRQL (which is
basically a deadlock), the page fault cannot be handled and you have an
unhandled exception on the fault (which causes a bluescreen of death)

d

From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Harsha Inamdar
Sent: Tuesday, December 13, 2005 6:56 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] IRQ Levels in windows OS

Hi All,

I have a question about IRQ Levels in windows. Why windows need them? Also I
would like to learn fundamentals of it.

Also I want to learn how is it related to paged pool memory & non paged pool
memory.

Any suggestions?

Thanks,
Harsha

Yahoo! Shopping
Find Great Deals on Holiday Gifts at Yahoo! Shopping — Questions? First
check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@microsoft.com To
unsubscribe send a blank email to xxxxx@lists.osr.com

You should ignore my post. I got a few wires crossed and my answer is not correct in the slightest. You should refer to Solomon and Russinovich’s Windows Internals 4th edition for the latest and greatest (and correct ;)) explanation.

Sorry
d


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Harsha Inamdar
Sent: Wednesday, December 14, 2005 11:51 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] IRQ Levels in windows OS

Thank you very much for your reply. I have solomon and russinovitch’s inside windows book. It has a sentence as “Although interrupt controllers perform a level of interrupt prioritization, windows imposes its own interrupt priority scheme known as IRQL.”
?
Now my question is why does windows need it? What are the advantages over interrupt controllers?
?
Thanks,
Harsha

Doron Holan wrote:
You should pick up solomon and russinovitch’s inside windows book (whatever the newest edition is). It explains IRQL very well.

As how it is related to paged memory, this is how (glossing over some details). When a page fault occurs, the memory subsystem will raise to dispatch level and bring in the page and then let the thread continue. If you are already at dispatch level when the page fault occurs, the memory subsystem cannot run since the OS is already running at that IRQL (which is basically a deadlock), the page fault cannot be handled and you have an unhandled exception on the fault (which causes a bluescreen of death)

d

From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Harsha Inamdar
Sent: Tuesday, December 13, 2005 6:56 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] IRQ Levels in windows OS

Hi All,
?
I have a question about IRQ Levels in windows. Why windows need them? Also I would like to learn fundamentals of it.
?
Also I want to learn how is it related to paged pool memory & non paged pool memory.
?
Any suggestions?
?
Thanks,
Harsha

Yahoo! Shopping
Find Great Deals on Holiday Gifts at Yahoo! Shopping — Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256 You are currently subscribed to ntdev as: xxxxx@microsoft.com To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

________________________________________
Yahoo! Shopping
Find Great Deals on Holiday Gifts at Yahoo! Shopping — Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256 You are currently subscribed to ntdev as: xxxxx@microsoft.com To unsubscribe send a blank email to xxxxx@lists.osr.com

> I have a question about IRQ Levels in windows. Why windows need them?

Some levels of current state of CPU in turns of preemptivity and
interuptability.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

>When a page fault occurs, the memory subsystem will raise to dispatch level
and

bring in the page and then let the thread continue.

To APC_LEVEL IIRC :slight_smile:

If you are already at dispatch level when the page fault occurs, the memory
subsystem cannot run since the OS is already running at that IRQL

In-page path has a KeWaitForSingleObject call in MiWaitForInPageComplete -
waiting for disk read of the page to complete.

One cannot call KeWaitForSingleObject from DISPATCH_LEVEL. Thus the “nonpaged
only” limitation on this IRQL.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

>Call) and DPC (Dispatch) levels. These are reserved for drivers and other OS

functionality that must run without OS preemption but that aren’t as important
as
an interrupt service routine.

APC_LEVEL is preemptive. You just cannot touch some kinds of locks there, and
you will never see the IopCompleteRequest completion and thus Irp->UserEvent
being signaled till you will drop to PASSIVE_LEVEL.

This, in turn, means - no ZwXxxFile calls from APC_LEVEL.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

> Now my question is why does windows need it? What are the advantages over
interrupt controllers?

Portability.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com