summaryrefslogtreecommitdiffstats
path: root/cpukit/libmisc/cpuuse
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2007-09-06 22:51:25 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2007-09-06 22:51:25 +0000
commit90a5d194a2712d7e28eafa1aac0b9fdb32e7b96b (patch)
tree251aff7b38cce4867fb2a77f5bbafa3b8ccb9785 /cpukit/libmisc/cpuuse
parent2007-09-06 Joel Sherrill <joel.sherrill@oarcorp.com> (diff)
downloadrtems-90a5d194a2712d7e28eafa1aac0b9fdb32e7b96b.tar.bz2
2007-09-06 Joel Sherrill <joel.sherrill@oarcorp.com>
* libcsupport/Makefile.am, libcsupport/src/printk.c: * libcsupport/src/printk_plugin.c: New file. include/rtems/bspIo.h, libmisc/cpuuse/cpuusagereport.c, libmisc/cpuuse/cpuuse.h, libmisc/stackchk/check.c, libmisc/stackchk/stackchk.h: rtems/include/rtems/rtems/ratemon.h, rtems/src/ratemonreportstatistics.c: Added capability to specify your own "printf" routine to various reporting functions. This added an XXX_with_plugin as the underlying implementation for + rtems_rate_monotonic_report_statistics + rtems_stack_checker_report_usage + rtems_cpu_usage_report As demonstration, the http netdemo can now print out stack and cpu usage reports.
Diffstat (limited to 'cpukit/libmisc/cpuuse')
-rw-r--r--cpukit/libmisc/cpuuse/cpuusagereport.c35
-rw-r--r--cpukit/libmisc/cpuuse/cpuuse.h13
2 files changed, 37 insertions, 11 deletions
diff --git a/cpukit/libmisc/cpuuse/cpuusagereport.c b/cpukit/libmisc/cpuuse/cpuusagereport.c
index 9c9bd4aef2..2a4c569e26 100644
--- a/cpukit/libmisc/cpuuse/cpuusagereport.c
+++ b/cpukit/libmisc/cpuuse/cpuusagereport.c
@@ -27,8 +27,7 @@
#include <rtems/cpuuse.h>
#include <rtems/bspIo.h>
-#if defined(RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS) || \
- defined(RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS)
+#if defined(RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS)
#include <rtems/score/timespec.h>
#endif
@@ -43,7 +42,10 @@
* rtems_cpu_usage_report
*/
-void rtems_cpu_usage_report( void )
+void rtems_cpu_usage_report_with_plugin(
+ void *context,
+ rtems_printk_plugin_t print
+)
{
uint32_t i;
uint32_t api_index;
@@ -57,6 +59,9 @@ void rtems_cpu_usage_report( void )
uint32_t total_units = 0;
#endif
+ if ( !print )
+ return;
+
/*
* When not using nanosecond CPU usage resolution, we have to count
* the number of "ticks" we gave credit for to give the user a rough
@@ -81,7 +86,10 @@ void rtems_cpu_usage_report( void )
}
#endif
- printk( "CPU Usage by thread\n"
+ #if defined(RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS)
+ (*print)( context, "--- CPU Usage times are seconds:microseconds ---\n" );
+ #endif
+ (*print)( context, "CPU Usage by thread\n"
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
" ID NAME SECONDS PERCENT\n"
#else
@@ -104,7 +112,7 @@ void rtems_cpu_usage_report( void )
rtems_object_get_name( the_thread->Object.id, sizeof(name), name );
- printk( "0x%08" PRIx32 " %4s ", the_thread->Object.id, name );
+ (*print)( context, "0x%08" PRIx32 " %4s ", the_thread->Object.id, name );
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
/*
@@ -124,7 +132,9 @@ void rtems_cpu_usage_report( void )
/*
* Print the information
*/
- printk("%2" PRId32 ".%06" PRId32 " %3" PRId32 ".%02" PRId32 "\n",
+
+ (*print)( context,
+ "%2" PRId32 ":%06" PRId32 " %3" PRId32 ".%02" PRId32 "\n",
ran.tv_sec, ran.tv_nsec / TOD_NANOSECONDS_PER_MICROSECOND,
ival, fval
);
@@ -133,7 +143,7 @@ void rtems_cpu_usage_report( void )
the_thread->ticks_executed * 10000 / total_units : 0;
fval = ival % 100;
ival /= 100;
- printk(
+ (*print)( context,
"%8" PRId32 " %3" PRId32 ".%02" PRId32"\n",
the_thread->ticks_executed,
ival,
@@ -145,16 +155,21 @@ void rtems_cpu_usage_report( void )
}
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
- printk( "Time since last CPU Usage reset %" PRId32
+ (*print)( context, "Time since last CPU Usage reset %" PRId32
".%06" PRId32 " seconds\n",
total.tv_sec,
total.tv_nsec / TOD_NANOSECONDS_PER_MICROSECOND
);
#else
- printk(
+ (*print)( context,
"Ticks since last reset = %" PRId32 "\n",
_Watchdog_Ticks_since_boot - CPU_usage_Ticks_at_last_reset
);
- printk( "Total Units = %" PRId32 "\n\n", total_units );
+ (*print)( context, "Total Units = %" PRId32 "\n\n", total_units );
#endif
}
+
+void rtems_cpu_usage_report( void )
+{
+ rtems_cpu_usage_report_with_plugin( NULL, printk_plugin );
+}
diff --git a/cpukit/libmisc/cpuuse/cpuuse.h b/cpukit/libmisc/cpuuse/cpuuse.h
index 994c80e90a..b38927e7c6 100644
--- a/cpukit/libmisc/cpuuse/cpuuse.h
+++ b/cpukit/libmisc/cpuuse/cpuuse.h
@@ -3,7 +3,7 @@
* This include file contains information necessary to utilize
* and install the cpu usage reporting mechanism.
*
- * COPYRIGHT (c) 1989-2006.
+ * COPYRIGHT (c) 1989-2007.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -16,11 +16,22 @@
#ifndef __RTEMS_CPUUSE_h
#define __RTEMS_CPUUSE_h
+#include <rtems/bspIo.h>
+
#ifdef __cplusplus
extern "C" {
#endif
/*
+ * rtems_cpu_usage_report_with_handler
+ */
+
+void rtems_cpu_usage_report_with_plugin(
+ void *context,
+ rtems_printk_plugin_t handler
+);
+
+/*
* rtems_cpu_usage_report
*/