ucos-ii 之 OSTimeTick
来源:互联网 发布:混沌战域仙翼进阶数据 编辑:程序博客网 时间:2024/05/01 11:30
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.
- ucos-ii 之 OSTimeTick
- uCOS-II之信号量
- uCOS-II之邮箱
- Ucos II 移植之二
- ucos-ii 之OSTaskDel函数
- ucos-ii 之OSTaskDelReq函数
- ucos-II之任务优先级
- STM之ucos-ii堆栈
- uCOS-ii之消息队列
- uCOS-II整理之任务
- OSTimeTick()
- uCOS II
- uCOS II 之事件控制块学习
- uCOS-ii内核的任务之二
- UCOS-II之字节对齐问题
- UCOS-II之字节对齐问题 sprintf
- nios2探索之uCOS-II移植
- UCOS II之学习笔记一
- JavaScirpt多个同时入栈和入队列顺序问题
- 关于C内存组织方式____结构体对齐
- log4j.properties配置详解
- js弹出的窗口居中显示
- du
- ucos-ii 之 OSTimeTick
- MySQL:如何编写UDF
- Cacti插件
- win7 安装 vc6.0的一点经验
- 类派生的时候构造函数的调用
- 关于宏定义
- tuxedo: 客户端远程调用与服务器监听配置
- Android 4.0的12大新特性
- 去掉字符串中重复的字符 --- 华为笔试题