summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems/src/ratemonreportstatistics.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2007-05-15 20:16:16 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2007-05-15 20:16:16 +0000
commite1bce866cf503c34f2914b76c9978bc598096013 (patch)
treed2419a46c38bc4d0eed2eaee219ec946de075596 /cpukit/rtems/src/ratemonreportstatistics.c
parent2007-05-15 Ray Xu <rayx@gmail.com> (diff)
downloadrtems-e1bce866cf503c34f2914b76c9978bc598096013.tar.bz2
2007-05-15 Joel Sherrill <joel.sherrill@oarcorp.com>
* Makefile.am, preinstall.am, libmisc/Makefile.am, rtems/Makefile.am, rtems/include/rtems.h, rtems/include/rtems/rtems/ratemon.h, rtems/inline/rtems/rtems/ratemon.inl, rtems/src/ratemoncancel.c, rtems/src/ratemoncreate.c, rtems/src/ratemondelete.c, rtems/src/ratemongetstatus.c, rtems/src/ratemonident.c, rtems/src/ratemonperiod.c, rtems/src/ratemontimeout.c, score/Makefile.am, score/include/rtems/score/object.h, score/src/threadhandler.c, wrapup/Makefile.am: Integrate Rate Monotonic Statistics and Period Usage into Rate Monotonic Manager. Added the following directives: rtems_rate_monotonic_get_statistics, rtems_rate_monotonic_reset_statistics, rtems_rate_montonic_reset_all_statistics, rtems_rate_montonic_report_statistics, and rtems_object_get_name. Obsoleted the rtems/rtmonuse.h file as a public interface. * rtems/src/ratemongetstatistics.c, rtems/src/ratemonreportstatistics.c, rtems/src/ratemonresetall.c, rtems/src/ratemonresetstatistics.c, rtems/src/rtemsobjectgetname.c, score/src/objectgetnameasstring.c: New files. * libmisc/rtmonuse/rtmonuse.c, libmisc/rtmonuse/rtmonuse.h: Removed.
Diffstat (limited to 'cpukit/rtems/src/ratemonreportstatistics.c')
-rw-r--r--cpukit/rtems/src/ratemonreportstatistics.c90
1 files changed, 90 insertions, 0 deletions
diff --git a/cpukit/rtems/src/ratemonreportstatistics.c b/cpukit/rtems/src/ratemonreportstatistics.c
new file mode 100644
index 0000000000..352bd1d946
--- /dev/null
+++ b/cpukit/rtems/src/ratemonreportstatistics.c
@@ -0,0 +1,90 @@
+/*
+ * Rate Monotonic Manager -- Report Statistics for All Periods
+ *
+ * COPYRIGHT (c) 1989-2007.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <inttypes.h>
+
+#include <rtems/bspIo.h>
+
+/*
+ * This directive allows a thread to print the statistics information
+ * on ALL period instances which have non-zero counts using printk.
+ *
+ * The implementation of this directive straddles the fence between
+ * inside and outside of RTEMS. It is presented as part of the Manager
+ * but actually uses other services of the Manager.
+ */
+void rtems_rate_montonic_report_statistics( void )
+{
+ rtems_status_code status;
+ rtems_id id;
+ rtems_rate_monotonic_period_statistics the_stats;
+ rtems_rate_monotonic_period_status the_status;
+ char name[5];
+ uint32_t ival_cpu, fval_cpu;
+ uint32_t ival_wall, fval_wall;
+
+ printk(
+ "Period information by period\n"
+ " ID OWNER PERIODS MISSED CPU TIME WALL TIME\n"
+ );
+
+ /*
+ * Cycle through all possible ids and try to report on each one. If it
+ * is a period that is inactive, we just get an error back. No big deal.
+ */
+ for ( id=_Rate_monotonic_Information.minimum_id ;
+ id <= _Rate_monotonic_Information.maximum_id ;
+ id++ ) {
+ status = rtems_rate_monotonic_get_statistics( id, &the_stats );
+ if ( status != RTEMS_SUCCESSFUL )
+ continue;
+
+ /* If the above passed, so should this but check it anyway */
+ status = rtems_rate_monotonic_get_status( id, &the_status );
+ if ( status != RTEMS_SUCCESSFUL )
+ continue;
+
+ if ( the_stats.count == 0 )
+ continue;
+
+ ival_cpu = the_stats.total_cpu_time * 100 / the_stats.count;
+
+ name[ 0 ] = '\0';
+
+ if ( the_status.owner ) {
+ rtems_object_get_name( the_status.owner, sizeof(name), name );
+ }
+
+ fval_cpu = ival_cpu % 100;
+ ival_cpu /= 100;
+ ival_wall = the_stats.total_wall_time * 100 / the_stats.count;
+ fval_wall = ival_wall % 100;
+ ival_wall /= 100;
+ printk(
+ "0x%08" PRIx32 " %4s %6" PRId32 " %3" PRId32 " "
+ "%" PRId32 "/%" PRId32 "/%" PRId32 ".%02" PRId32 " "
+ "%" PRId32 "/%" PRId32 "/%" PRId32 ".%02" PRId32 "\n",
+ id, name,
+ the_stats.count, the_stats.missed_count,
+ the_stats.min_cpu_time, the_stats.max_cpu_time, ival_cpu, fval_cpu,
+ the_stats.min_wall_time, the_stats.max_wall_time, ival_wall, fval_wall
+ );
+ }
+}