diff options
| author | Grissiom <[email protected]> | 2013-12-21 11:56:33 +0800 |
|---|---|---|
| committer | Grissiom <[email protected]> | 2013-12-21 11:59:22 +0800 |
| commit | 5019b3ee14e461fc6f39457efd7b18d842e09a9c (patch) | |
| tree | 6d7dbb0f8fded8524f099738645110c15fde0878 /examples/kernel/cpuusage.c | |
| parent | 6b02886eb381e5758a3977444e5d4d78419e8c5a (diff) | |
TC: format code, expand TABs
No functional changes.
Diffstat (limited to 'examples/kernel/cpuusage.c')
| -rw-r--r-- | examples/kernel/cpuusage.c | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/examples/kernel/cpuusage.c b/examples/kernel/cpuusage.c index 05c9b7a8c4..93cac1bb99 100644 --- a/examples/kernel/cpuusage.c +++ b/examples/kernel/cpuusage.c @@ -9,62 +9,62 @@ static rt_uint32_t total_count = 0; static void cpu_usage_idle_hook() { - rt_tick_t tick; - rt_uint32_t count; - volatile rt_uint32_t loop; + rt_tick_t tick; + rt_uint32_t count; + volatile rt_uint32_t loop; - if (total_count == 0) - { - /* get total count */ - rt_enter_critical(); - tick = rt_tick_get(); - while(rt_tick_get() - tick < CPU_USAGE_CALC_TICK) - { - total_count ++; - loop = 0; - while (loop < CPU_USAGE_LOOP) loop ++; - } - rt_exit_critical(); - } + if (total_count == 0) + { + /* get total count */ + rt_enter_critical(); + tick = rt_tick_get(); + while(rt_tick_get() - tick < CPU_USAGE_CALC_TICK) + { + total_count ++; + loop = 0; + while (loop < CPU_USAGE_LOOP) loop ++; + } + rt_exit_critical(); + } - count = 0; - /* get CPU usage */ - tick = rt_tick_get(); - while (rt_tick_get() - tick < CPU_USAGE_CALC_TICK) - { - count ++; - loop = 0; - while (loop < CPU_USAGE_LOOP) loop ++; - } + count = 0; + /* get CPU usage */ + tick = rt_tick_get(); + while (rt_tick_get() - tick < CPU_USAGE_CALC_TICK) + { + count ++; + loop = 0; + while (loop < CPU_USAGE_LOOP) loop ++; + } - /* calculate major and minor */ - if (count < total_count) - { - count = total_count - count; - cpu_usage_major = (count * 100) / total_count; - cpu_usage_minor = ((count * 100) % total_count) * 100 / total_count; - } - else - { - total_count = count; + /* calculate major and minor */ + if (count < total_count) + { + count = total_count - count; + cpu_usage_major = (count * 100) / total_count; + cpu_usage_minor = ((count * 100) % total_count) * 100 / total_count; + } + else + { + total_count = count; - /* no CPU usage */ - cpu_usage_major = 0; - cpu_usage_minor = 0; - } + /* no CPU usage */ + cpu_usage_major = 0; + cpu_usage_minor = 0; + } } void cpu_usage_get(rt_uint8_t *major, rt_uint8_t *minor) { - RT_ASSERT(major != RT_NULL); - RT_ASSERT(minor != RT_NULL); + RT_ASSERT(major != RT_NULL); + RT_ASSERT(minor != RT_NULL); - *major = cpu_usage_major; - *minor = cpu_usage_minor; + *major = cpu_usage_major; + *minor = cpu_usage_minor; } void cpu_usage_init() { - /* set idle thread hook */ - rt_thread_idle_sethook(cpu_usage_idle_hook); + /* set idle thread hook */ + rt_thread_idle_sethook(cpu_usage_idle_hook); } |
