mirror of
https://github.com/apache/nuttx.git
synced 2026-09-09 02:16:35 +00:00
sched/sched: Fix roundrobin scheduler timer if SCHED_TICKLESS enabled
In tickless mode, the scheduler timer is stopped whenever the currently running task requires no time slicing (CLOCK_MAX). When a SCHED_RR task was later switched in, nothing re-armed the timer, so the task could run indefinitely without round-robin rotation. Reassess the scheduler timer in nxsched_switch_context() before the context switch when the task being switched in uses round-robin scheduling, so that the timer is always armed while an RR task is running. Hooking into nxsched_switch_context() covers all context switch paths (task context switch, interrupt exit, syscall and task exit) since every architecture calls it on every switch. Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
This commit is contained in:
parent
f134a5678d
commit
be9200f95a
1 changed files with 9 additions and 0 deletions
|
|
@ -65,6 +65,15 @@ void nxsched_switch_context(FAR struct tcb_s *from, FAR struct tcb_s *to)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_SCHED_TICKLESS) && CONFIG_RR_INTERVAL > 0
|
||||
/* Before the context switch, we should set the timer for RR. */
|
||||
|
||||
if (from != to && (to->flags & TCB_FLAG_POLICY_MASK) == TCB_FLAG_SCHED_RR)
|
||||
{
|
||||
nxsched_reassess_timer();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Indicate that the task has been suspended */
|
||||
|
||||
#ifdef CONFIG_SCHED_CRITMONITOR
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue