3.定时器的扫描过程
真正开始扫描定时器的就是上述的KiRetireDpcList 检测到PRCB的定时器请求是true 调用KiTimerExpiration
//解除定时器的操作
VOID
KiTimerExpiration (
IN PKDPC TimerDpc,
IN PVOID DeferredContext,
IN PVOID SystemArgument1,
IN PVOID SystemArgument2
)
/*++
Routine Description:
This function is called when the clock interupt routine discovers that
a timer has expired.
N.B. This function executes on the same processor that receives clock
interrupts.
Arguments:
TimerDpc - Not used.
DeferredContext - Not used.
SystemArgument1 - Supplies the starting timer table index value to
use for the timer table scan.
SystemArgument2 - Not used.
Return Value:
None.
--*/
{
ULARGE_INTEGER CurrentTime;
ULONG DpcCount;
PKDPC Dpc;
DPC_ENTRY DpcTable[MAXIMUM_TIMERS_PROCESSED];
KIRQL DummyIrql;
LONG HandLimit;
LONG Index;
LARGE_INTEGER Interval;
PLIST_ENTRY ListHead;
PKSPIN_LOCK_QUEUE LockQueue;
PLIST_ENTRY NextEntry;
KIRQL OldIrql;
LONG Period;
#if !defined(NT_UP) || defined(_WIN64)
PKPRCB Prcb = KeGetCurrentPrcb();
#endif
ULARGE_INTEGER SystemTime;
PKTIMER Timer;
ULONG TimersExamined;
ULONG TimersProcessed;
UNREFERENCED_PARAMETER(TimerDpc);
UNREFERENCED_PARAMETER(DeferredContext);
UNREFERENCED_PARAMETER(SystemArgument2);
//
// Capture the timer expiration time, the current interrupt time, and
// the low tick count.
//
// N.B. Interrupts are disabled to ensure that interrupt activity on the
// current processor does not cause the values read to be skewed.
//
_disable();
KiQuerySystemTime((PLARGE_INTEGER)&SystemTime);
KiQueryInterruptTime((PLARGE_INTEGER)&CurrentTime);
HandLimit = (LONG)KiQueryLowTickCount();
_enable();
//
// If the timer table has not wrapped, then start with the specified
// timer table index value, and scan for timer entries that have expired.
// Otherwise, start with the specified timer table index value and scan
// the entire table for timer entries that have expired.
//
// N.B. This later condition exists when DPC processing is blocked for a
// period longer than one round trip throught the timer table.
//
// N.B. Th

本文深入探讨了DPC(Deferred Procedure Calls)定时器的扫描过程,从KiRetireDpcList函数检测到PRCB的定时器请求开始,详细阐述了KiTimerExpiration如何计算时间差并遍历链表,将到期的DPC放入缓存表或插入到DPC链表中进行处理,从而揭示了DPC定时器的工作机制。
&spm=1001.2101.3001.5002&articleId=7580305&d=1&t=3&u=7e39dc6ce09c47de8f6f448b0999c833)
1741

被折叠的 条评论
为什么被折叠?



