sched:sched_cpuload_oneshot: add time compensate for idle task

Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>
This commit is contained in:
zhuyanlin 2022-04-22 17:48:27 +08:00 committed by Xiang Xiao
parent 6facf18a01
commit c75f4b62e0

View File

@ -101,6 +101,8 @@ struct sched_oneshot_s
#endif #endif
#ifdef CONFIG_PM #ifdef CONFIG_PM
struct pm_callback_s pm_cb; struct pm_callback_s pm_cb;
clock_t idle_start;
clock_t idle_ticks;
#endif #endif
}; };
@ -237,11 +239,24 @@ static void nxsched_oneshot_pmnotify(FAR struct pm_callback_s *cb,
{ {
if (pmstate == PM_RESTORE) if (pmstate == PM_RESTORE)
{ {
g_sched_oneshot.idle_ticks +=
clock_systime_ticks() - g_sched_oneshot.idle_start;
if (g_sched_oneshot.idle_ticks >= CPULOAD_ONESHOT_NOMINAL)
{
nxsched_process_cpuload_ticks(
g_sched_oneshot.idle_ticks / CPULOAD_ONESHOT_NOMINAL);
g_sched_oneshot.idle_ticks %= CPULOAD_ONESHOT_NOMINAL;
}
nxsched_oneshot_start(); nxsched_oneshot_start();
} }
else else
{ {
ONESHOT_CANCEL(g_sched_oneshot.oneshot, NULL); ONESHOT_CANCEL(g_sched_oneshot.oneshot, NULL);
g_sched_oneshot.idle_start = clock_systime_ticks();
} }
} }
} }