diff --git a/sched/sched/sched_addreadytorun.c b/sched/sched/sched_addreadytorun.c index 2724a1bd5acb7..c22571df8a183 100644 --- a/sched/sched/sched_addreadytorun.c +++ b/sched/sched/sched_addreadytorun.c @@ -103,6 +103,17 @@ bool nxsched_add_readytorun(FAR struct tcb_s *btcb) btcb->flink->task_state = TSTATE_TASK_READYTORUN; up_update_task(btcb); ret = true; + +#if defined(CONFIG_SCHED_TICKLESS) && CONFIG_RR_INTERVAL > 0 + /* Tickless has no periodic tick to keep RR accounting alive, so + * arm the new task's timeslice timer explicitly on switch-in. + */ + + if ((btcb->flags & TCB_FLAG_POLICY_MASK) == TCB_FLAG_SCHED_RR) + { + nxsched_reassess_timer(); + } +#endif } else { diff --git a/sched/wdog/wdog.h b/sched/wdog/wdog.h index bd726af57d791..c52a986dbc2db 100644 --- a/sched/wdog/wdog.h +++ b/sched/wdog/wdog.h @@ -176,7 +176,14 @@ static inline_function void wd_timer_start(clock_t tick, bool in_expiration) #ifdef CONFIG_SCHED_TICKLESS_ALARM up_alarm_tick_start(next_tick); #else - up_timer_tick_start(next_tick - clock_systime_ticks()); + clock_t delta = next_tick - clock_systime_ticks(); + + /* Clamp to >= 1 tick: an already-expired 'delta' can go negative + * (overflows unsigned in arch code), and even zero can miss a + * oneshot timer's rising-edge match if the target is already due. + */ + + up_timer_tick_start(delta > 0 ? delta : 1); #endif }