コード例 #1
0
ファイル: os_core.c プロジェクト: fulong/armucos
void  OSTimeTick (void)
{
#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr;
#endif    
    OS_TCB    *ptcb;


    OSTimeTickHook();                                      /* Call user definable hook                 */
#if OS_TIME_GET_SET_EN > 0   
    OS_ENTER_CRITICAL();                                   /* Update the 32-bit tick counter           */
    OSTime++;
    OS_EXIT_CRITICAL();
#endif
    if (OSRunning == TRUE) {    
        ptcb = OSTCBList;                                  /* Point at first TCB in TCB list           */
        while (ptcb->OSTCBPrio != OS_IDLE_PRIO) {          /* Go through all TCBs in TCB list          */
            OS_ENTER_CRITICAL();
            if (ptcb->OSTCBDly != 0) {                     /* Delayed or waiting for event with TO     */
                if (--ptcb->OSTCBDly == 0) {               /* Decrement nbr of ticks to end of delay   */
                    if ((ptcb->OSTCBStat & OS_STAT_SUSPEND) == OS_STAT_RDY) { /* Is task suspended?    */
                        OSRdyGrp               |= ptcb->OSTCBBitY; /* No,  Make task R-to-R (timed out)*/
                        OSRdyTbl[ptcb->OSTCBY] |= ptcb->OSTCBBitX;
                    } else {                               /* Yes, Leave 1 tick to prevent ...         */
                        ptcb->OSTCBDly = 1;                /* ... loosing the task when the ...        */
                    }                                      /* ... suspension is removed.               */
                }
            }
            ptcb = ptcb->OSTCBNext;                        /* Point at next TCB in TCB list            */
            OS_EXIT_CRITICAL();
        }
    }
}
コード例 #2
0
ファイル: os_time.c プロジェクト: redmorningcn/NC136B-320
void  OSTimeTick (void)
{
#if ((OS_CFG_TASK_TICK_EN == DEF_ENABLED) || (OS_CFG_TMR_EN == DEF_ENABLED))
    OS_ERR  err;
#endif


    if (OSRunning != OS_STATE_OS_RUNNING) {
        return;
    }

    OSTimeTickHook();                                           /* Call user definable hook                             */

#if (OS_CFG_TASK_TICK_EN == DEF_ENABLED)

   (void)OSTaskSemPost(&OSTickTaskTCB,                          /* Signal tick task                                     */
                        OS_OPT_POST_NONE,
                       &err);


#if (OS_CFG_SCHED_ROUND_ROBIN_EN == DEF_ENABLED)
    OS_SchedRoundRobin(&OSRdyList[OSPrioCur]);
#endif

#if (OS_CFG_TMR_EN == DEF_ENABLED)
    OSTmrUpdateCtr--;
    if (OSTmrUpdateCtr == 0u) {
        OSTmrUpdateCtr = OSTmrUpdateCnt;
        (void)OSTaskSemPost(&OSTmrTaskTCB,                      /* Signal timer task                                    */
                             OS_OPT_POST_NONE,
                            &err);
    }
#endif
#endif
}
コード例 #3
0
void  OSTimeTick (void)
{
    OS_ERR  err;
#if OS_CFG_ISR_POST_DEFERRED_EN > 0u
    CPU_TS  ts;
#endif


    OSTimeTickHook();                                       /* Call user definable hook                               */

#if OS_CFG_ISR_POST_DEFERRED_EN > 0u

    ts = OS_TS_GET();                                       /* Get timestamp                                          */
    OS_IntQPost((OS_OBJ_TYPE) OS_OBJ_TYPE_TICK,             /* Post to ISR queue                                      */
                (void      *)&OSRdyList[OSPrioCur],
                (void      *) 0,
                (OS_MSG_SIZE) 0u,
                (OS_FLAGS   ) 0u,
                (OS_OPT     ) 0u,
                (CPU_TS     ) ts,
                (OS_ERR    *)&err);

#else

   (void)OSTaskSemPost((OS_TCB *)&OSTickTaskTCB,            /* Signal tick task                                       */
                       (OS_OPT  ) OS_OPT_POST_NONE,
                       (OS_ERR *)&err);


#if OS_CFG_SCHED_ROUND_ROBIN_EN > 0u
    OS_SchedRoundRobin(&OSRdyList[OSPrioCur]);
#endif

#if OS_CFG_TMR_EN > 0u
    OSTmrUpdateCtr--;
    if (OSTmrUpdateCtr == (OS_CTR)0u) {
        OSTmrUpdateCtr = OSTmrUpdateCnt;
        OSTaskSemPost((OS_TCB *)&OSTmrTaskTCB,              /* Signal timer task                                      */
                      (OS_OPT  ) OS_OPT_POST_NONE,
                      (OS_ERR *)&err);
    }
#endif

#endif
}
コード例 #4
0
ファイル: os_time.c プロジェクト: redmorningcn/NC136B-320
void OSTimeDynTick (OS_TICK ticks)
{
    OS_ERR  err;
    CPU_SR_ALLOC();


    if (OSRunning != OS_STATE_OS_RUNNING) {
        return;
    }

    OSTimeTickHook();

    CPU_CRITICAL_ENTER();
    OSTickCtrPend += ticks;
    CPU_CRITICAL_EXIT();

    (void)OSTaskSemPost(&OSTickTaskTCB,                          /* Signal tick task                                     */
                         OS_OPT_POST_NONE,
                        &err);

}
コード例 #5
0
ファイル: OS_CORE.C プロジェクト: orkash/UCOS_Learn
//时钟节拍函数 PROCESS SYSTEM TICK
//描述: uC/OS需要用户提供周期性信号源,用于实现时间延时和确认超时。节拍率应在每秒10次到100次
//		之间,或者说10到100Hz。时钟节拍率越高,系统的额外负荷就越重.时钟节拍的实际频率取决于
//		用户应用程序的精度。时钟节拍源可以是专门的硬件定时器,也可以是来自50/60Hz交流电源的
//		信号														   
//参数: 无
//返回: 无
void  OSTimeTick (void)
{
#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr;
#endif    
    OS_TCB    *ptcb; //定义任务控制块优先级表变量


    OSTimeTickHook();                                      //调用户·自定义函数(钩子函数)
#if OS_TIME_GET_SET_EN > 0   
    OS_ENTER_CRITICAL();                                   //累加从开机以来的时间,用的是一个无符号32位变量
    OSTime++;
    OS_EXIT_CRITICAL();
#endif
    if (OSRunning == TRUE) {    
        ptcb = OSTCBList;                                  //保存任务控制块列表首地址
														   //从OSTCBList开始,沿着OS_TCB链表做,一直做到空闲任务
        while (ptcb->OSTCBPrio != OS_IDLE_PRIO) {          /* Go through all TCBs in TCB list          */
            OS_ENTER_CRITICAL();
            if (ptcb->OSTCBDly != 0) {                     //如果任务等待时的最多节拍数不为0
										   				//而确切被任务挂起的函数OSTaskSuspend()挂起的任务则不会进入就绪态
														//执行时间直接与应用程序中建立了多少个务成正比
             if (--ptcb->OSTCBDly == 0) {               //如果任务等待时的最多节拍数为0
														//当某任务的任务控制块中的时间延时项OSTCBDly减到了零,这个任务就进入了就绪态
                    if ((ptcb->OSTCBStat & OS_STAT_SUSPEND) == OS_STAT_RDY) { /* Is task suspended?    */
                        OSRdyGrp               |= ptcb->OSTCBBitY; /* No,  Make task R-to-R (timed out)*/
                        OSRdyTbl[ptcb->OSTCBY] |= ptcb->OSTCBBitX;
                    } else {                               /* Yes, Leave 1 tick to prevent ...         */
                        ptcb->OSTCBDly = 1;                /* ... loosing the task when the ...        */
                    }                                      /* ... suspension is removed.               */
                }
            }
            ptcb = ptcb->OSTCBNext;                        //指向任务块双向链接表的后链接
            OS_EXIT_CRITICAL();
        }
    }
}