First, make sure you understand that the current DPC level is per-processor, not per-system. So, the scheduler doesn’t “stop scheduling normal threads” when the current processor raises to DPC_LEVEL or above. The scheduler simply guarantees that the current processor will not perform a context swap to another thread. Also, there is no such thing as a “normal thread” vs. a “non-normal thread”. To the scheduler, it’s all just… threads.
The scheduler is not some active entity in the system. It is a passive library of functions, and the associated system-wide data structures and per-processor data structures that those functions manipulate. Access to the system-wide data structures is synchronized. Access to the per-processor control block is mostly unsynchronized (hey, it’s just one processor, right?), although there are times when access to certain parts of that structure are synchronized as well.
There are no threads dedicated to “the scheduler” – they’re all owned by the scheduler. The scheduler is a set of mechanisms that control which thread will be run at a given time. It is not itself a thread, or a set of threads. (Unless you mean “all threads” by “a set of threads”.)
So, the general pattern is this. A user-mode thread lives most of its life at PASSIVE_LEVEL. When a hardware interrupt occurs, the processor executes an ISR, which sets the DPC level of the current processor to the device IRQL of the associated interrupt. Since this is always > DISPATCH_LEVEL, the current thread cannot change.
The main job of the device-specific ISR code is to 1) verify that the device associated with the ISR really is asserting its interrupt line, 2) turn off the interrupt line, and then 3) schedule a DPC to deal with the changed state of the device “later”.
The OS ISR code then attempts to lower the DPC level to what it was before the ISR fired. If lowering the DPC level would cause a transition from DPC_LEVEL or higher to a lower level (PASSIVE or APC), then the kernel scans the queued DPC list, and executes items in that list. The idea is that inserting into that list is cheap (no allocations, O(1)) and safe (non-paged pool for all participants, so safe no matter what thread is active on the processor).
The DPC list is part of the per-processor control block. So when you queue a DPC, by default, it will be queued for execution on the current processor. You can specify that a DPC should be executed on a preferred processor (affinitized DPCs, using KeSetTargetProcessorDpc), for special occasions.
“P” in your mail is controlled simply by how often DPCs are queued, and how long each individual DPC routine runs. On a given processor, no code will ever run at PASSIVE_LEVEL or APC_LEVEL until all DPCs queued on that processor have been completed. Which means that, as long as DPCs are queued on a processor, the thread on that processor will not be rescheduled. However, keep in mind that one processor can be at DPC_LEVEL (or device IRQL, or anything), while another processor is running at a completely different IRQL.
In other words, there is no periodic “P” time interval. The DPC queue (on the current processor) is drained by the time the IRQL level moves to APC_LEVEL or PASSIVE_LEVEL (on the current processor).
On the current processor.
– arlie
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of bank kus
Sent: Wednesday, October 04, 2006 2:18 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] WHQL to detect rogue drivers
In fact may I follow up on this with another question, some of these aspects are not very clear in Inside Windows 2000:
How does the whole dpc scheduling operation tie up with that of normal thread scheduling.
So my understanding is that at a period `P’, the DPC queue will be flushed of all its queued objects. Meaning, at such time, the scheduler stops scheduling normal threads, raises system to dispatch level and clears the dpc queue.
Question is when such takes place, is it atomic ? Meaning is it true that once started *ALL* dpc objects will be executed before normal thread scheduling takes place again?
**What can impact ‘P’? ( other than lenghty ISR routines ? ) Is there such a ‘P’ at all?
thanks
banks
“bank kus” wrote in message news:xxxxx@ntdev…
> Looking at the following link it seems there were plans to have a
> WHQL requirement for drivers not to spin too much time in their
> dpc/isr routines.
> http://www.microsoft.com/whdc/driver/perform/mmdrv.mspx
>
> Curious if such has been implemented already for Windows XP?
>
> thanks
> banks
>
>
—
Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer**