ucos-ii 之 OSTimeTick

简介:  OSTimeTick() basically consist of decrementing the OSTCBDly field for each OS_TCB (if it‘s nonzero).


 OSTimeTick() basically consist of decrementing the OSTCBDly field for each OS_TCB (if it‘s nonzero).

 OSTimeTick() follows the chain of OS_TCB starting at OSTCBList L3.20(2) until it reaches the idle task L3.20(3).

 When the OSTCBDly field of a task’s OS_TCB is decremented to zero, the task is made ready to run L3.20(4).

 The task is not readied, however, if it was explicitly suspended by OSTaskSuspend() L3.20(5).

 The execution time of OSTimeTick() is directly proportional to the number of tasks created in an application.

void OSTimeTick (void)
{
    OS_TCB *ptcb;
    OSTimeTickHook();						(1)
    ptcb = OSTCBList;						(2)
    while (ptcb->OSTCBPrio != OS_IDLE_PRIO) {     		(3)
        OS_ENTER_CRITICAL();
        if (ptcb->OSTCBDly != 0) { 
            if (--ptcb->OSTCBDly == 0) { 
                if (!(ptcb->OSTCBStat & OS_STAT_SUSPEND)) {  	(5)
                     OSRdyGrp |= ptcb->OSTCBBitY;		(4)
                    OSRdyTbl[ptcb->OSTCBY] |= ptcb->OSTCBBitX;
                } else {
                    ptcb->OSTCBDly = 1;
                } 
            }
        }
        ptcb = ptcb->OSTCBNext; 
        OS_EXIT_CRITICAL();
    }
    OS_ENTER_CRITICAL(); 					(7)
    OSTime++;                                                   (6)
    OS_EXIT_CRITICAL(); 
}


 OSTimeTick() also accumulates the number of clock ticks since power up in an unsigned 32-bit variable called OSTime L3.20(6).

 Note that I disable interrupts L3.20(7) before incrementing OSTime because on some processors, a 32-bit increment will most likely be done using multiple instructions.

相关文章
|
API
FreeRTOS学习笔记—FreeRTOS移植
本文学习了如何移植FreeRTOS到自己的STM32工程。最后,根据正点原子提供的测试main函数,测试了移植效果。
521 0
FreeRTOS学习笔记—FreeRTOS移植
|
6月前
|
消息中间件 Web App开发 API
FreeRTOS介绍 和 将FreeRTOS移植到STM32F103C8T6
FreeRTOS介绍 和 将FreeRTOS移植到STM32F103C8T6
FreeRTOS介绍 和 将FreeRTOS移植到STM32F103C8T6
|
5月前
|
消息中间件 算法 编译器
【FreeRTOS(一)】FreeRTOS新手入门——初识FreeRTOS
【FreeRTOS(一)】FreeRTOS新手入门——初识FreeRTOS
|
消息中间件 算法 安全
RTOS实时操作系统中RT-Thread、FreeRTOS和uCOS 选择哪一个学习比较好?
RTOS实时操作系统中RT-Thread、FreeRTOS和uCOS 选择哪一个学习比较好?
STM32F103移值FreeRtos笔记
STM32F103移值FreeRtos笔记
102 0
|
物联网 Java 编译器
嵌入式操作系统——uCOS
嵌入式操作系统——uCOS
605 0
|
测试技术 API
FreeRTOS-stm32f407移植
FreeRTOS-stm32f407移植
FreeRTOS-stm32f407移植
|
Web App开发 C语言 Linux
uCOS_II.C
  Lin-credible!  Linux内核读不懂,先读读 uCOS的中文注释的源码! 1 /* 2 ************************************************************************************************* 3 *
1339 0
|
编译器
uCos-III移植到STM32F10x
最近在百度上看了uCOS-III 的介绍后,诸多功能有很大的提升和改进,感觉有必要升级一下开发环境。百度介绍:http://baike.baidu.com/view/8531313.htm 环境: STM32F10x 3.5固件库。
1286 0