summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems/src/ratemonreportstatistics.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2007-05-17 22:46:45 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2007-05-17 22:46:45 +0000
commitc3330a88ee5d674b09dded32ef1ccba26a9c3034 (patch)
treef7f247449fc18bc299ef695c3503f9b7790db97a /cpukit/rtems/src/ratemonreportstatistics.c
parentAdd .rh clause to extra_arg. (diff)
downloadrtems-c3330a88ee5d674b09dded32ef1ccba26a9c3034.tar.bz2
2007-05-17 Joel Sherrill <joel.sherrill@oarcorp.com>
* ChangeLog, configure.ac, libcsupport/src/__times.c, libmisc/cpuuse/cpuuse.c, libmisc/stackchk/check.c, rtems/include/rtems/rtems/ratemon.h, rtems/src/ratemongetstatus.c, rtems/src/ratemonperiod.c, rtems/src/ratemonreportstatistics.c, rtems/src/ratemonresetall.c, rtems/src/ratemontimeout.c, score/Makefile.am, score/include/rtems/score/thread.h, score/include/rtems/score/timespec.h, score/src/threaddispatch.c, score/src/threadinitialize.c, score/src/threadtickletimeslice.c, score/src/timespecdivide.c: Add nanoseconds granularity to the rate monotonic period statistics and CPU usage statistics. This capability is enabled by default although may be conditionally disabled by the user. It could be too much overhead on small targets but it does not appear to be bad in early testing. Its impact on code size has not been evaluated either. It is possible that both forms of statistics gathering could be disabled with further tweaking of the conditional compilation. * score/src/timespecdividebyinteger.c: New file.
Diffstat (limited to 'cpukit/rtems/src/ratemonreportstatistics.c')
-rw-r--r--cpukit/rtems/src/ratemonreportstatistics.c129
1 files changed, 110 insertions, 19 deletions
diff --git a/cpukit/rtems/src/ratemonreportstatistics.c b/cpukit/rtems/src/ratemonreportstatistics.c
index 352bd1d946..35f3c6d30b 100644
--- a/cpukit/rtems/src/ratemonreportstatistics.c
+++ b/cpukit/rtems/src/ratemonreportstatistics.c
@@ -22,6 +22,15 @@
#include <rtems/bspIo.h>
+#if defined(RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS) || \
+ defined(RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS)
+ #include <rtems/score/timespec.h>
+
+ /* We print to 1/10's of milliseconds */
+ #define NANOSECONDS_DIVIDER 100000
+ #define PERCENT_FMT "%04" PRId32
+#endif
+
/*
* This directive allows a thread to print the statistics information
* on ALL period instances which have non-zero counts using printk.
@@ -30,19 +39,36 @@
* 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 )
+void rtems_rate_monotonic_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"
+ printk( "Period information by period\n" );
+/*
+Layout by columns -- in memory of Hollerith :)
+
+1234567890123456789012345678901234567890123456789012345678901234567890123456789\
+ ID OWNER COUNT MISSED X
+ididididid NNNN ccccc mmmmmm X
+
+ Uncomment the following if you are tinkering with the formatting.
+ Be sure to test the various cases.
+ printk("\
+1234567890123456789012345678901234567890123456789012345678901234567890123456789\
+\n");
+*/
+ printk( " ID OWNER COUNT MISSED CPU TIME "
+ #ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
+ " "
+ #endif
+ #ifdef RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS
+ " "
+ #endif
+ " WALL TIME\n"
);
/*
@@ -64,27 +90,92 @@ void rtems_rate_montonic_report_statistics( void )
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;
+ /*
+ * Print part of report line that is not dependent on granularity
+ */
+
printk(
- "0x%08" PRIx32 " %4s %6" PRId32 " %3" PRId32 " "
- "%" PRId32 "/%" PRId32 "/%" PRId32 ".%02" PRId32 " "
- "%" PRId32 "/%" PRId32 "/%" PRId32 ".%02" PRId32 "\n",
+ "0x%08" PRIx32 " %4s %5" PRId32 " %6" PRId32 " ",
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
+ the_stats.count, the_stats.missed_count
);
+
+ /*
+ * print CPU Usage part of statistics
+ */
+ {
+ #ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
+ struct timespec cpu_average;
+
+ _Timespec_Divide_by_integer(
+ &the_stats.total_cpu_time,
+ the_stats.count,
+ &cpu_average
+ );
+ printk(
+ "%" PRId32 "." PERCENT_FMT "/" /* min cpu time */
+ "%" PRId32 "." PERCENT_FMT "/" /* max cpu time */
+ "%" PRId32 "." PERCENT_FMT " ", /* avg cpu time */
+ the_stats.min_cpu_time.tv_sec,
+ the_stats.min_cpu_time.tv_nsec / NANOSECONDS_DIVIDER,
+ the_stats.max_cpu_time.tv_sec,
+ the_stats.max_cpu_time.tv_nsec / NANOSECONDS_DIVIDER,
+ cpu_average.tv_sec,
+ cpu_average.tv_nsec / NANOSECONDS_DIVIDER
+ );
+ #else
+ uint32_t ival_cpu, fval_cpu;
+
+ ival_cpu = the_stats.total_cpu_time * 100 / the_stats.count;
+ fval_cpu = ival_cpu % 100;
+ ival_cpu /= 100;
+
+ printk(
+ "%3" PRId32 "/%4" PRId32 "/%3" PRId32 ".%02" PRId32 " ",
+ the_stats.min_cpu_time, the_stats.max_cpu_time, ival_cpu, fval_cpu
+ );
+ #endif
+ }
+
+ /*
+ * print Wall time part of statistics
+ */
+ {
+ #ifdef RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS
+ struct timespec wall_average;
+ _Timespec_Divide_by_integer(
+ &the_stats.total_wall_time,
+ the_stats.count,
+ &wall_average
+ );
+ printk(
+ "%" PRId32 "." PERCENT_FMT "/" /* min wall time */
+ "%" PRId32 "." PERCENT_FMT "/" /* max wall time */
+ "%" PRId32 "." PERCENT_FMT "\n", /* avg wall time */
+ the_stats.min_wall_time.tv_sec,
+ the_stats.min_wall_time.tv_nsec / NANOSECONDS_DIVIDER,
+ the_stats.max_wall_time.tv_sec,
+ the_stats.max_wall_time.tv_nsec / NANOSECONDS_DIVIDER,
+ wall_average.tv_sec,
+ wall_average.tv_nsec / NANOSECONDS_DIVIDER
+ );
+ #else
+ uint32_t ival_wall, fval_wall;
+
+ ival_wall = the_stats.total_wall_time * 100 / the_stats.count;
+ fval_wall = ival_wall % 100;
+ ival_wall /= 100;
+ printk(
+ "%3" PRId32 "/%4" PRId32 "/%3" PRId32 ".%02" PRId32 "\n",
+ the_stats.min_wall_time, the_stats.max_wall_time, ival_wall, fval_wall
+ );
+ #endif
+ }
}
}