summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2011-03-07 14:55:05 +0000
committerSebastian Huber <sebastian.huber@embedded-brains.de>2011-03-07 14:55:05 +0000
commitdb498aba754bb4a5d5f7c9c6943733a3c520026f (patch)
tree81bb526e7a612006d491e0deeab2cf11ee190d1e
parent2011-03-07 Sebastian Huber <sebastian.huber@embedded-brains.de> (diff)
downloadrtems-db498aba754bb4a5d5f7c9c6943733a3c520026f.tar.bz2
2011-03-07 Sebastian Huber <sebastian.huber@embedded-brains.de>
* libmisc/cpuuse/cpuusagereport.c: Fix calculation in case a thread dispatch happends in the meantime. The percent values will not sum up to one hundred percent.
-rw-r--r--cpukit/ChangeLog3
-rw-r--r--cpukit/libmisc/cpuuse/cpuusagereport.c15
2 files changed, 12 insertions, 6 deletions
diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog
index db2d226ba0..f22b250d80 100644
--- a/cpukit/ChangeLog
+++ b/cpukit/ChangeLog
@@ -2,6 +2,9 @@
* include/rtems/irq-extension.h: Documentation.
* libmisc/monitor/mon-prmisc.c: Fix for multiprocessing configuration.
+ * libmisc/cpuuse/cpuusagereport.c: Fix calculation in case a thread
+ dispatch happends in the meantime. The percent values will not sum up
+ to one hundred percent.
2011-03-04 Ralf Corsépius <ralf.corsepius@rtems.org>
diff --git a/cpukit/libmisc/cpuuse/cpuusagereport.c b/cpukit/libmisc/cpuuse/cpuusagereport.c
index 5f4f51bd1f..2002987cdf 100644
--- a/cpukit/libmisc/cpuuse/cpuusagereport.c
+++ b/cpukit/libmisc/cpuuse/cpuusagereport.c
@@ -53,7 +53,7 @@ void rtems_cpu_usage_report_with_plugin(
char name[13];
uint32_t ival, fval;
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
- Timestamp_Control uptime, total, ran, last_context_switch;
+ Timestamp_Control uptime, total, ran, uptime_at_last_reset;
#else
uint32_t total_units = 0;
#endif
@@ -67,9 +67,7 @@ void rtems_cpu_usage_report_with_plugin(
* guideline as to what each number means proportionally.
*/
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
- last_context_switch = _Thread_Time_of_last_context_switch;
- _TOD_Get_uptime( &uptime );
- _Timestamp_Subtract( &CPU_usage_Uptime_at_last_reset, &uptime, &total );
+ uptime_at_last_reset = CPU_usage_Uptime_at_last_reset;
#else
for ( api_index = 1 ; api_index <= OBJECTS_APIS_LAST ; api_index++ ) {
#if !defined(RTEMS_POSIX_API) || defined(RTEMS_DEBUG)
@@ -133,9 +131,14 @@ void rtems_cpu_usage_report_with_plugin(
ran = the_thread->cpu_time_used;
if ( _Thread_Executing->Object.id == the_thread->Object.id ) {
Timestamp_Control used;
- _Timestamp_Subtract( &last_context_switch, &uptime, &used );
+ Timestamp_Control last = _Thread_Time_of_last_context_switch;
+ _TOD_Get_uptime( &uptime );
+ _Timestamp_Subtract( &last, &uptime, &used );
_Timestamp_Add_to( &ran, &used );
- };
+ } else {
+ _TOD_Get_uptime( &uptime );
+ }
+ _Timestamp_Subtract( &uptime_at_last_reset, &uptime, &total );
_Timestamp_Divide( &ran, &total, &ival, &fval );
/*