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. 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.
Note:
原文出处: μC/OS-II,The Real-Time Kernel Jean J. Labrosse
本文详细介绍了μC/OS-II实时操作系统内核中时间滴答处理函数OSTimeTick()的工作原理。该函数通过遍历任务控制块链表,减少每个活动任务的延时计数,当任务的延时计数减为0时,将其设置为就绪状态。此外,文章还提到了中断禁用以确保时间递增操作的原子性。
677

被折叠的 条评论
为什么被折叠?



