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.
-----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?
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).
>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.