diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2011-06-16 16:24:05 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2011-06-16 16:24:05 +0000 |
commit | c1a84bf816a2aa006a75c3aa58fde6c41ee2c2b0 (patch) | |
tree | 06fc07c6ca66e7a0378940095a5ecf569efa59dd | |
parent | Fix spelling error. (diff) | |
download | rtems-c1a84bf816a2aa006a75c3aa58fde6c41ee2c2b0.tar.bz2 |
2011-06-16 Joel Sherrill <joel.sherrill@oarcorp.com>
PR 1818/misc
* libmisc/cpuuse/cpuusagereport.c: Add SMP support to CPU Usage
Reporting.
-rw-r--r-- | cpukit/ChangeLog | 6 | ||||
-rw-r--r-- | cpukit/libmisc/cpuuse/cpuusagereport.c | 36 |
2 files changed, 37 insertions, 5 deletions
diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog index 242df94737..b6210dd4f6 100644 --- a/cpukit/ChangeLog +++ b/cpukit/ChangeLog @@ -1,3 +1,9 @@ +2011-06-16 Joel Sherrill <joel.sherrill@oarcorp.com> + + PR 1818/misc + * libmisc/cpuuse/cpuusagereport.c: Add SMP support to CPU Usage + Reporting. + 2011-06-16 Jennifer Averett <Jennifer Averett@OARcorp.com * score/src/smp.c: Spinlock Name change necessary to resolve diff --git a/cpukit/libmisc/cpuuse/cpuusagereport.c b/cpukit/libmisc/cpuuse/cpuusagereport.c index 92445520b7..4e2fe455e2 100644 --- a/cpukit/libmisc/cpuuse/cpuusagereport.c +++ b/cpukit/libmisc/cpuuse/cpuusagereport.c @@ -36,11 +36,34 @@ extern uint32_t CPU_usage_Ticks_at_last_reset; #endif -/*PAGE - * +#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ + static bool is_executing_on_a_core( + Thread_Control *the_thread, + Timestamp_Control *time_of_context_switch + ) + { + #ifndef RTEMS_SMP + if ( _Thread_Executing->Object.id == the_thread->Object.id ) { + *time_of_context_switch = _Thread_Time_of_last_context_switch; + return true; + } + #else + int cpu; + for ( cpu=0 ; cpu < _SMP_Processor_count ; cpu++ ) { + Per_CPU_Control *p = &_Per_CPU_Information[cpu]; + if ( p->executing->Object.id == the_thread->Object.id ) { + *time_of_context_switch = p->time_of_last_context_switch; + return true; + } + } + #endif + return false; + } +#endif + +/* * rtems_cpu_usage_report */ - void rtems_cpu_usage_report_with_plugin( void *context, rtems_printk_plugin_t print @@ -125,14 +148,16 @@ void rtems_cpu_usage_report_with_plugin( ); #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ + { + Timestamp_Control last; + /* * If this is the currently executing thread, account for time * since the last context switch. */ ran = the_thread->cpu_time_used; - if ( _Thread_Executing->Object.id == the_thread->Object.id ) { + if ( is_executing_on_a_core( the_thread, &last ) ) { Timestamp_Control used; - Timestamp_Control last = _Thread_Time_of_last_context_switch; _TOD_Get_uptime( &uptime ); _Timestamp_Subtract( &last, &uptime, &used ); _Timestamp_Add_to( &ran, &used ); @@ -153,6 +178,7 @@ void rtems_cpu_usage_report_with_plugin( TOD_NANOSECONDS_PER_MICROSECOND, ival, fval ); + } #else if (total_units) { uint64_t ival_64; |