2,644
社区成员




A Deferred procedure call (DPC) is a Windows operating system mechanism which allows high-priority tasks (e.g. an interrupt handler) to defer required but lower-priority tasks for later execution. This permits device drivers and other low-level event consumers to perform the high-priority part of their processing quickly, and schedule non-critical additional processing for execution at a lower priority.
DPCs are implemented by DPC objects which are created and initialized by the kernel when a device driver or some other kernel mode program issues requests for DPC. The DPC request is then added to the end of the system-wide DPC queue. DPCs have three priority levels: low, medium and high. By default, all DPCs are set to medium priority. When the processor drops to an IRQL (interrupt request level) of Dispatch/DPC level, it checks the DPC queue for any pending(等候判定或决定) DPCs and executes them until the queue is empty or some other interrupt with a higher IRQL occurs.
For example, when the clock interrupt is generated(产生), the clock interrupt handler generally increments the counter of the current thread to calculate the total execution time of that thread, and decrements its quantum(定量) time remaining by 1(要在1以上). When the counter drops to zero, the thread scheduler has to be invoked to choose the next thread to be executed on that processor and dispatcher to perform a context switch(上下文切换). Since the clock interrupt occurs at a much higher IRQL, it will be desirable to perform this thread dispatching which is a less critical task at a later time when the processor's IRQL drops. So the clock interrupt handler requests a DPC object and adds it to the end of the DPC queue which will process the dispatching when the processor's IRQL drops to DPC/Dispatch level.
一句话:为了保持高响应, 延迟执行高IRQL的任务。
PS:要么不执行。 要么抽干整个DPC队列。