sched/critmonitor: Restore the target run start time.

The context-switch merge assigned the current timestamp to run_time instead of run_start. This overwrote the accumulated runtime and left the next elapsed-time calculation with a stale start value when critical-monitor CPU load accounting was disabled.

Store the timestamp in run_start under the thread runtime monitor configuration, matching the former resume path.

Fixes: b2a69ba781 ("sched: merge nxsched_suspend/resume_critmon")
Assisted-by: OpenAI Codex
Signed-off-by: yushuailong <yyyusl@qq.com>
This commit is contained in:
yushuailong 2026-09-06 22:30:54 +08:00 committed by Xiang Xiao
parent 23d2eb96f3
commit 170d02da21

View file

@ -377,12 +377,11 @@ void nxsched_switch_critmon(FAR struct tcb_s *from, FAR struct tcb_s *to)
clock_t tick = elapsed * CLOCKS_PER_SEC / perf_getfreq();
nxsched_critmon_cpuload(from, current, tick);
to->run_start = current;
#endif
#if CONFIG_SCHED_CRITMONITOR_MAXTIME_THREAD >= 0
from->run_time += elapsed;
to->run_time = current;
to->run_start = current;
if (elapsed > from->run_max)
{
from->run_max = elapsed;