【UCOSIII】4.时间片

1 UCOSIII 时间片轮转调度
      时间片轮转调度器用于时间片轮转调度,为函数OS_SchedRoundRobin(),
此函数由 OSTimeTick 或者 OS_IntQTask() 调用,函数在文件 os_core.c 中定义。
2.1 OSSchedRoundRobinCfg() 函数:
      如果我们想要使用UCOSIII 的时间片轮转调度的话不仅要将宏 OS_CFG_SCHED_ROUND_ROBIN_EN 1 ,还需要调用函数 OSSchedRoundRobinCfg() ,函数原型如下
 void  OSSchedRoundRobinCfg (CPU_BOOLEAN  en,
                OS_TICK    dflt_time_quanta,
                OS_ERR     *p_err)
2.2 OSSchedRoundRobinYield() 函数:
    当一个任务想要放弃本次时间片的时候,就可以调用该函数,函数原型如下:
void  OSSchedRoundRobinYield (OS_ERR  *p_err)
  函数OSSchedRoundRobinYield()使用示例如下:
void Task(void *p_arg)
{
     OS_RR err;
     while(1)
     {
  ……
   OSSchedRoundRobinYield(&err);
  …..
     }
}

猜你喜欢

转载自blog.csdn.net/qq_22555959/article/details/80928534