DPC,时钟中断,以及DPC定时器(3)

本文深入探讨了DPC(Deferred Procedure Calls)定时器的扫描过程,从KiRetireDpcList函数检测到PRCB的定时器请求开始,详细阐述了KiTimerExpiration如何计算时间差并遍历链表,将到期的DPC放入缓存表或插入到DPC链表中进行处理,从而揭示了DPC定时器的工作机制。
摘要由CSDN通过智能技术生成

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. The current instance of the timer expiration execution w
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值