Can an DPC be preempted by an ISR?

Hi,

This may look like a very stupid question but i just want to recollect my basics.

If i queue a DPC from an ISR with out masking interrupt on the device, then while the DPC is being executed, if another interrupt occurs, then will the currently executing DPC be preempted by the ISR?

If yes, how this happens exactly? because the schedule can’t run at DPC level hence ISR can’t be scheduled to run by the OS. I am just wondering how else ISR can preempt the DPC?

ISR’s aren’t scheduled exactly - they happen in response to an interrupt,
which is unrelated to the scheduler. They run at a higher IRQL than DPC’s,
and they are protected by a spinlock that the system acquires befor it
executes your ISR.

This is a really good introduction to the topic, written mostly by someone
who frequents this list quite a bit:
http://download.microsoft.com/download/e/b/a/eba1050f-a31d-436b-9281-92cdfea
e4b45/IRQL_thread.doc

mm

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@gmail.com
Sent: Saturday, November 01, 2014 7:53 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Can an DPC be preempted by an ISR?

Hi,

This may look like a very stupid question but i just want to recollect my
basics.

If i queue a DPC from an ISR with out masking interrupt on the device, then
while the DPC is being executed, if another interrupt occurs, then will the
currently executing DPC be preempted by the ISR?

If yes, how this happens exactly? because the schedule can’t run at DPC
level hence ISR can’t be scheduled to run by the OS. I am just wondering how
else ISR can preempt the DPC?


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

A DPC can be interrupted by an ISR, including the ISR for the same device (if interrupts remain enabled). The ISR could also run on a different processor, queue another DPC, and thus result in your DPC running in parallel on two processors.

To be clear: You used the word “pre-empted”… technically neither DPCs nor ISRs are scheduled, there for neither is subject to “preemption”, which is a scheduler-based mechanism as mm explained.

But, to answer the essence of your question, the answer is YES… if you leave interrupts enabled on your device, your ISR can INTERRUPT your DPC. This is because your DPC runs at IRQL DISPATCH_LEVEL whereas your ISR runs as a Device IRQL (which is *always* higher than IRQL DISPATCH_LEVEL).

Peter
OSR
@OSRDrivers

>will the currently executing DPC be preempted by the ISR?

Yes.


Maxim S. Shatskih
Microsoft MVP on File System And Storage
xxxxx@storagecraft.com
http://www.storagecraft.com

>will the currently executing DPC be preempted by the ISR?

It depends on what the DPC is “doing” when the interrupt occurs. If the DPC has called KeSynchronizeExecution (WDM) or WdfInterruptSynchronize (KMDF) than it is not preempted, otherwise it is. So the answer is yes and no.