首页 > 编程语言 > 详细

从时钟中断到线程调度的分析(二)

时间:2016-05-14 18:37:48      阅读:338      评论:0      收藏:0      [点我收藏+]

    既然时钟中断函数是HalpClockInterrupt,那就从它开始研究,WRK没有公布它,还是从reactos开始看吧,reactos是仿windows,所以可能和windows原版有些差别,不过差别不大

VOID FASTCALL HalpClockInterruptHandler(IN PKTRAP_FRAME TrapFrame)
{
    ULONG LastIncrement;
    KIRQL Irql;3

    /* Enter trap */
    KiEnterInterruptTrap(TrapFrame);

    /* Start the interrupt */
    if (ghhghhjvc(CLOCK2_LEVEL, PRIMARY_VECTOR_BASE, &Irql))
    {
        /* Update the performance counter */
        HalpPerfCounter.QuadPart += HalpCurrentRollOver;
        HalpPerfCounterCutoff = KiEnableTimerWatchdog;

        /* Save increment */
        LastIncrement = HalpCurrentTimeIncrement;

        /* Check if someone changed the time rate */
        if (HalpClockSetMSRate)
        {
            /* Update the global values */
            HalpCurrentTimeIncrement = HalpRolloverTable[HalpNextMSRate - 1].Increment;
            HalpCurrentRollOver = HalpRolloverTable[HalpNextMSRate - 1].RollOver;

            /* Set new timer rollover */
            HalpSetTimerRollOver((USHORT)HalpCurrentRollOver);

            /* We‘re done */
            HalpClockSetMSRate = FALSE;
        }

        /* Update the system time -- the kernel will exit this trap  */
        KeUpdateSystemTime(TrapFrame, LastIncrement, Irql);  更新系统时间
    } 

    /* Spurious, just end the interrupt */
    KiEoiHelper(TrapFrame);
}

     时钟中断最后会调用KeUpdateSystemTime,所以看看这个函数是干嘛的

 

从时钟中断到线程调度的分析(二)

原文:http://www.cnblogs.com/testvt/p/5492994.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!