⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vartick.c

📁 Windows CE 6.0 BSP for VOIPAC Board (PXA270) Version 2b.
💻 C
字号:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
#include <windows.h>
#include <nkintr.h>
#include <pkfuncs.h>
#include <oal.h>

//------------------------------------------------------------------------------
//
//  Function:  OALTimerUpdateRescheduleTime
//
//  This function is called by kernel to set next reschedule time.
//
VOID OALTimerUpdateRescheduleTime(DWORD time)
{
    UINT32 baseMSec, diffMSec, diffCounts;
    INT32 counts;

    // Get current system timer counter
    baseMSec = CurMSec;

    // Return if we are already setup correctly
    if (time == (baseMSec + g_oalTimer.actualMSecPerSysTick)) goto cleanUp;

    // How far we are from next tick
    counts = g_oalTimer.actualCountsPerSysTick - OALTimerCountsSinceSysTick();

    // If timer interrupts occurs, or we are within 1 ms of the scheduled
    // interrupt, just return - timer ISR will take care of it.
    if (baseMSec != CurMSec || counts < (INT32)g_oalTimer.countsPerMSec) {
        goto cleanUp;
    }        

    // Calculate the distance between the new time and the last timer interrupt
    diffMSec = time - baseMSec;

    // Trying to set reschedule time prior or equal to CurMSec - this could
    // happen if a thread is on its way to sleep while preempted before
    // getting into the Sleep Queue
    if ((INT32)diffMSec < 0) diffMSec = 0;

    // Account for limitation (we are using msecPerSysTick instead
    // maxPeriodMSec - this allows little more ways how to modify timer
    // behavior, but in most cases those values will be same)
    if (diffMSec > g_oalTimer.msecPerSysTick) {
        diffMSec = g_oalTimer.msecPerSysTick;
    }        

    // Calculate count difference
    diffCounts = diffMSec * g_oalTimer.countsPerMSec;

    // Actual values to be used by interrupt handler
    g_oalTimer.actualMSecPerSysTick = diffMSec;
    g_oalTimer.actualCountsPerSysTick = diffCounts;

    // Reduct actual timer period (implementation must shift interrupt time
    // if we are too close to new tick time)
    OALTimerUpdate(diffCounts, g_oalTimer.countsMargin);

cleanUp:
    return;    
}

//------------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -