sched:sched_cpuload_oneshot: add time compensate for idle task
Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>
This commit is contained in:
parent
6facf18a01
commit
c75f4b62e0
@ -101,6 +101,8 @@ struct sched_oneshot_s
|
||||
#endif
|
||||
#ifdef CONFIG_PM
|
||||
struct pm_callback_s pm_cb;
|
||||
clock_t idle_start;
|
||||
clock_t idle_ticks;
|
||||
#endif
|
||||
};
|
||||
|
||||
@ -237,11 +239,24 @@ static void nxsched_oneshot_pmnotify(FAR struct pm_callback_s *cb,
|
||||
{
|
||||
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();
|
||||
}
|
||||
else
|
||||
{
|
||||
ONESHOT_CANCEL(g_sched_oneshot.oneshot, NULL);
|
||||
|
||||
g_sched_oneshot.idle_start = clock_systime_ticks();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user