diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2011-03-07 14:55:05 +0000 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2011-03-07 14:55:05 +0000 |
commit | db498aba754bb4a5d5f7c9c6943733a3c520026f (patch) | |
tree | 81bb526e7a612006d491e0deeab2cf11ee190d1e /cpukit/libmisc/cpuuse/cpuusagereport.c | |
parent | 2011-03-07 Sebastian Huber <sebastian.huber@embedded-brains.de> (diff) | |
download | rtems-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.
Diffstat (limited to '')
-rw-r--r-- | cpukit/libmisc/cpuuse/cpuusagereport.c | 15 |
1 files changed, 9 insertions, 6 deletions
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 ); /* |