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

📄 tmt.c

📁 nucleus在S3C2410下的移植全套源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
/*                                                                       */
/*      None                                                             */
/*                                                                       */
/* HISTORY                                                               */
/*                                                                       */
/*         NAME            DATE                    REMARKS               */
/*                                                                       */
/*      W. Lamie        xx-xx-199x      Created initial version 1.0      */
/*      D. Lamie        xx-xx-199x      Verified version 1.0             */
/*                                                                       */
/*************************************************************************/
VOID  TMT_Disable_Timer(VOID)
{

    /* Disable the count-down timer.  */
    TMD_Timer_State =  TM_NOT_ACTIVE;
}



/*************************************************************************/
/*                                                                       */
/* FUNCTION                                                              */
/*                                                                       */
/*      TMT_Retrieve_TS_Task                                             */
/*                                                                       */
/* DESCRIPTION                                                           */
/*                                                                       */
/*      This function returns the time-sliced task pointer.              */
/*                                                                       */
/* AUTHOR                                                                */
/*                                                                       */
/*      William E. Lamie, Accelerated Technology, Inc.                   */
/*                                                                       */
/* CALLED BY                                                             */
/*                                                                       */
/*      TMC_Timer_HISR                      Timer HISR                   */
/*                                                                       */
/* CALLS                                                                 */
/*                                                                       */
/*      None                                                             */
/*                                                                       */
/* INPUTS                                                                */
/*                                                                       */
/*      None                                                             */
/*                                                                       */
/* OUTPUTS                                                               */
/*                                                                       */
/*      TMD_Time_Slice_Task                 Time sliced task pointer     */
/*                                                                       */
/* HISTORY                                                               */
/*                                                                       */
/*         NAME            DATE                    REMARKS               */
/*                                                                       */
/*      W. Lamie        xx-xx-199x      Created initial version 1.0      */
/*      D. Lamie        xx-xx-199x      Verified version 1.0             */
/*                                                                       */
/*************************************************************************/
NU_TASK  *TMT_Retrieve_TS_Task(VOID)
{

    /* Return time-sliced task pointer.  */
    return((NU_TASK *) TMD_Time_Slice_Task);
}



/*************************************************************************/
/*                                                                       */
/* FUNCTION                                                              */
/*                                                                       */
/*      TMT_Timer_Interrupt                                              */
/*                                                                       */
/* DESCRIPTION                                                           */
/*                                                                       */
/*      This function processes the actual hardware interrupt.           */
/*      Processing includes updating the system clock and the count-     */
/*      down timer and the time-slice timer.  If one or both of the      */
/*      timers expire, the timer HISR is activated.                      */
/*                                                                       */
/* AUTHOR                                                                */
/*                                                                       */
/*      William E. Lamie, Accelerated Technology, Inc.                   */
/*                                                                       */
/* CALLED BY                                                             */
/*                                                                       */
/*      Interrupt Vector                                                 */
/*                                                                       */
/* CALLS                                                                 */
/*                                                                       */
/*      TCT_Activate_HISR                   Activate timer HISR          */
/*      TCT_Interrupt_Context_Save          Save interrupted context     */
/*      TCT_Interrupt_Context_Restore       Restore interrupted context  */
/*                                                                       */
/* INPUTS                                                                */
/*                                                                       */
/*      None                                                             */
/*                                                                       */
/* OUTPUTS                                                               */
/*                                                                       */
/*      None                                                             */
/*                                                                       */
/* HISTORY                                                               */
/*                                                                       */
/*         NAME            DATE                    REMARKS               */
/*                                                                       */
/*      W. Lamie        xx-xx-199x      Created initial version 1.0      */
/*      D. Lamie        xx-xx-199x      Verified version 1.0             */
/*                                                                       */
/*************************************************************************/
extern void XXX(void);
VOID  TMT_Timer_Interrupt(VOID)
{

    /* Save minimal context on the stack.  */

    /* Increment the system clock.  */
    TMD_System_Clock++;
    
    /* Determine if the count-down timer is active.  */
    if (TMD_Timer_State == TM_ACTIVE)
    {
    
        /* Decrement the count-down timer.  */
        TMD_Timer--;
        
        /* Determine if the timer has expired. If so, modify the state 
           to indicate that it has expired.  */
        if (TMD_Timer == 0)
        
            TMD_Timer_State =  TM_EXPIRED;
    }
    
    /* Determine if the time-slice timer is active.  Note that the parameters
       for the time-slice are controlled by the Thread Control (TC) 
       component.  */
    if (TMD_Time_Slice_State == TM_ACTIVE)
    {
    
        /* Decrement the time slice counter.  */
        TMD_Time_Slice--;
        
        /* Determine if the time-slice timer has expired. If so, modify the
           time-slice state to indicate that it has.  */
        if (TMD_Time_Slice == 0)
        {
                
            TMD_Time_Slice_State =  TM_EXPIRED;

            /* Task Check        99.11.05  */
            if ((TCD_Current_Thread) &&
                (((TC_TCB *) TCD_Current_Thread) -> tc_id == TC_TASK_ID)){

            /* Copy the current thread into the time-slice task pointer.  */
            TMD_Time_Slice_Task =  TCD_Current_Thread;

            ((TC_TCB *) TCD_Current_Thread) -> tc_cur_time_slice =  1;//Why?

            }
            /*  99.11.05 */

        }
    }
    
    /* Determine if either of the basic timers have expired.  If so, 
       activate the timer HISR.  */
    if ((TMD_Timer_State == TM_EXPIRED) ||
        (TMD_Time_Slice_State == TM_EXPIRED))
    {
//        XXX();

        /* Save context of the system.  */
//        TCT_Interrupt_Context_Save();
      
        /* Activate the HISR timer function.  */
        TCT_Activate_HISR((NU_HISR *) &TMD_HISR);
       
        /* Restore context.  */
//        TCT_Interrupt_Context_Restore();

    }

}

⌨️ 快捷键说明

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