summaryrefslogtreecommitdiff
path: root/nuttx/sched
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-02-27 11:16:15 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-02-27 11:16:15 -0600
commit7267d55e379aca0ac0f0ba270c1f5e01476bdc4e (patch)
tree157cf0397e5f64ac2b024d70ca61ad7b92dfcaa8 /nuttx/sched
parentbbf818f7f9f6663cd9fba941167a59c7bd5eee0b (diff)
downloadpx4-nuttx-7267d55e379aca0ac0f0ba270c1f5e01476bdc4e.tar.gz
px4-nuttx-7267d55e379aca0ac0f0ba270c1f5e01476bdc4e.tar.bz2
px4-nuttx-7267d55e379aca0ac0f0ba270c1f5e01476bdc4e.zip
Fix how CPU load counts are adjusted so that the total always adds up to 100%
Diffstat (limited to 'nuttx/sched')
-rw-r--r--nuttx/sched/sched_cpuload.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/nuttx/sched/sched_cpuload.c b/nuttx/sched/sched_cpuload.c
index 802977f87..0f5495750 100644
--- a/nuttx/sched/sched_cpuload.c
+++ b/nuttx/sched/sched_cpuload.c
@@ -121,16 +121,21 @@ void weak_function sched_process_cpuload(void)
if (++g_cpuload_total > (CONFIG_SCHED_CPULOAD_TIMECONSTANT * CLOCKS_PER_SEC))
{
- /* Divide the tick count for every task by two */
+ uint32_t total = 0;
+
+ /* Divide the tick count for every task by two and recalculate the
+ * total.
+ */
for (i = 0; i < CONFIG_MAX_TASKS; i++)
{
g_pidhash[i].ticks >>= 1;
+ total += g_pidhash[i].ticks;
}
- /* Divide the total tick count by two */
+ /* Save the new total. */
- g_cpuload_total >>= 1;
+ g_cpuload_total = total;
}
}