sched: fix the bug of task's tmeslice

The BUG is as follow:
 1. Suppose there are two ready tasks t1 and t2 have the same priority, and t1 is the running.
 2. A new, higher priority task t0 (such as hpwork) is ready, then switch to t0.
 3. After t0 is suspended, then switch to t1 and reset the t1's timeslice.
 4. goto 2
The t2 will have no chance to run.

Signed-off-by: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
This commit is contained in:
walker.zeng 2021-12-13 17:25:38 +08:00 committed by Xiang Xiao
parent 2159315571
commit 76b2f7199d

View file

@ -57,21 +57,7 @@
void nxsched_resume_scheduler(FAR struct tcb_s *tcb)
{
#if CONFIG_RR_INTERVAL > 0
#ifdef CONFIG_SCHED_SPORADIC
if ((tcb->flags & TCB_FLAG_POLICY_MASK) == TCB_FLAG_SCHED_RR)
#endif
{
/* Reset the task's timeslice. */
tcb->timeslice = MSEC2TICK(CONFIG_RR_INTERVAL);
}
#endif
#ifdef CONFIG_SCHED_SPORADIC
#if CONFIG_RR_INTERVAL > 0
else
#endif
if ((tcb->flags & TCB_FLAG_POLICY_MASK) == TCB_FLAG_SCHED_SPORADIC)
{
/* Reset the replenishment cycle if it is appropriate to do so */