Jump to content

Deferred Procedure Call

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Becksguy (talk | contribs) at 15:04, 2 May 2008 (Added some refs, clarify lede). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

A Deferred procedure call (DPC) is a computer operating system mechanism which allows the processor while executing a critical task (i.e. the interrupt request level (IRQL) of the processor is high) to perform less critical tasks by deferring their execution to some later time when the processor's IRQL drops to Dispatch/DPC level or below. It helps the processor to quickly return from a higher IRQL where all the interrupts below the current IRQL are blocked completely by performing only those tasks needed to be performed at that IRQL.

DPCs are implemented by DPC objects which are created and initialised 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 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 much 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. 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.

References

  • [1] - Microsoft tech article on DPC
  • [2] - Microsoft definition of DPC
  • Art Baker & Jerry Lozano. (2000). Windows® 2000 Device Driver Book: A Guide for Programmers, Second Edition, The. Prentice Hall. ISBN 978-0-13-020431-8.