2007-10-26 Glenn Humphrey <glenn.humphrey@OARcorp.com>

* libmisc/cpuuse/cpuusagereport.c, rtems/src/ratemonreportstatistics.c:
	Cleaned up reports and fixed a bug related the printf format which
	resulted in lack of leading zeroes and misleading magnitude.
	* score/src/timespecdivide.c: Fixed bugs related to zero divide case.
This commit is contained in:
Glenn Humphrey
2007-10-26 21:31:04 +00:00
parent 3ab4ba719a
commit 0f4f543279
4 changed files with 62 additions and 34 deletions

View File

@@ -1,3 +1,10 @@
2007-10-26 Glenn Humphrey <glenn.humphrey@OARcorp.com>
* libmisc/cpuuse/cpuusagereport.c, rtems/src/ratemonreportstatistics.c:
Cleaned up reports and fixed a bug related the printf format which
resulted in lack of leading zeroes and misleading magnitude.
* score/src/timespecdivide.c: Fixed bugs related to zero divide case.
2007-10-19 Joel Sherrill <joel.sherrill@OARcorp.com> 2007-10-19 Joel Sherrill <joel.sherrill@OARcorp.com>
* telnetd/icmds.c: Add header to file. * telnetd/icmds.c: Add header to file.

View File

@@ -86,11 +86,8 @@ void rtems_cpu_usage_report_with_plugin(
} }
#endif #endif
#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" (*print)( context, "CPU Usage by thread\n"
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS #if defined(RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS)
" ID NAME SECONDS PERCENT\n" " ID NAME SECONDS PERCENT\n"
#else #else
" ID NAME TICKS PERCENT\n" " ID NAME TICKS PERCENT\n"
@@ -134,7 +131,7 @@ void rtems_cpu_usage_report_with_plugin(
*/ */
(*print)( context, (*print)( context,
"%2" PRId32 ":%06" PRId32 " %3" PRId32 ".%02" PRId32 "\n", "%3" PRId32 ".%06" PRId32 " %3" PRId32 ".%03" PRId32 "\n",
ran.tv_sec, ran.tv_nsec / TOD_NANOSECONDS_PER_MICROSECOND, ran.tv_sec, ran.tv_nsec / TOD_NANOSECONDS_PER_MICROSECOND,
ival, fval ival, fval
); );
@@ -165,7 +162,7 @@ void rtems_cpu_usage_report_with_plugin(
"Ticks since last reset = %" PRId32 "\n", "Ticks since last reset = %" PRId32 "\n",
_Watchdog_Ticks_since_boot - CPU_usage_Ticks_at_last_reset _Watchdog_Ticks_since_boot - CPU_usage_Ticks_at_last_reset
); );
(*print)( context, "Total Units = %" PRId32 "\n\n", total_units ); (*print)( context, "Total Units = %" PRId32 "\n", total_units );
#endif #endif
} }

View File

@@ -29,7 +29,7 @@
/* We print to 1/10's of milliseconds */ /* We print to 1/10's of milliseconds */
#define NANOSECONDS_DIVIDER 1000 #define NANOSECONDS_DIVIDER 1000
#define PERCENT_FMT "%04" PRId32 #define PERCENT_FMT "%04" PRId32
#define NANOSECONDS_FMT "%" PRId32 #define NANOSECONDS_FMT "%06" PRId32
#endif #endif
/* /*
@@ -55,12 +55,11 @@ void rtems_rate_monotonic_report_statistics_with_plugin(
return; return;
(*print)( context, "Period information by period\n" ); (*print)( context, "Period information by period\n" );
#if defined(RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS)
(*print)( context, "--- Period times are seconds:microseconds ---\n" );
#endif
#if defined(RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS) #if defined(RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS)
(*print)( context, "--- CPU Usage times are seconds:microseconds ---\n" ); (*print)( context, "--- CPU times are in seconds ---\n" );
#endif
#if defined(RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS)
(*print)( context, "--- Wall times are in seconds ---\n" );
#endif #endif
/* /*
Layout by columns -- in memory of Hollerith :) Layout by columns -- in memory of Hollerith :)
@@ -71,11 +70,15 @@ ididididid NNNN ccccc mmmmmm X
Uncomment the following if you are tinkering with the formatting. Uncomment the following if you are tinkering with the formatting.
Be sure to test the various cases. Be sure to test the various cases.
*/
(*print)( context,"\ (*print)( context,"\
1234567890123456789012345678901234567890123456789012345678901234567890123456789\ 1234567890123456789012345678901234567890123456789012345678901234567890123456789\
\n"); \n");
(*print)( context, " ID OWNER COUNT MISSED CPU TIME " */
(*print)( context, " ID OWNER COUNT MISSED "
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
" "
#endif
"CPU TIME "
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS #ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
" " " "
#endif #endif
@@ -84,6 +87,19 @@ ididididid NNNN ccccc mmmmmm X
#endif #endif
" WALL TIME\n" " WALL TIME\n"
); );
(*print)( context, " "
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
" "
#endif
"MIN/MAX/AVG "
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
" "
#endif
#ifdef RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS
" "
#endif
" MIN/MAX/AVG\n"
);
/* /*
* Cycle through all possible ids and try to report on each one. If it * Cycle through all possible ids and try to report on each one. If it
@@ -101,9 +117,6 @@ ididididid NNNN ccccc mmmmmm X
if ( status != RTEMS_SUCCESSFUL ) if ( status != RTEMS_SUCCESSFUL )
continue; continue;
if ( the_stats.count == 0 )
continue;
name[ 0 ] = '\0'; name[ 0 ] = '\0';
if ( the_status.owner ) { if ( the_status.owner ) {
@@ -120,6 +133,15 @@ ididididid NNNN ccccc mmmmmm X
the_stats.count, the_stats.missed_count the_stats.count, the_stats.missed_count
); );
/*
* If the count is zero, don't print statistics
*/
if (the_stats.count == 0) {
(*print)( context, "\n" );
continue;
}
/* /*
* print CPU Usage part of statistics * print CPU Usage part of statistics
*/ */
@@ -133,9 +155,9 @@ ididididid NNNN ccccc mmmmmm X
&cpu_average &cpu_average
); );
(*print)( context, (*print)( context,
"%" PRId32 ":" NANOSECONDS_FMT "/" /* min cpu time */ "%" PRId32 "." NANOSECONDS_FMT "/" /* min cpu time */
"%" PRId32 ":" NANOSECONDS_FMT "/" /* max cpu time */ "%" PRId32 "." NANOSECONDS_FMT "/" /* max cpu time */
"%" PRId32 ":" NANOSECONDS_FMT " ", /* avg cpu time */ "%" PRId32 "." NANOSECONDS_FMT " ", /* avg cpu time */
the_stats.min_cpu_time.tv_sec, the_stats.min_cpu_time.tv_sec,
the_stats.min_cpu_time.tv_nsec / NANOSECONDS_DIVIDER, the_stats.min_cpu_time.tv_nsec / NANOSECONDS_DIVIDER,
the_stats.max_cpu_time.tv_sec, the_stats.max_cpu_time.tv_sec,
@@ -169,9 +191,9 @@ ididididid NNNN ccccc mmmmmm X
&wall_average &wall_average
); );
(*print)( context, (*print)( context,
"%" PRId32 ":" PERCENT_FMT "/" /* min wall time */ "%" PRId32 "." NANOSECONDS_FMT "/" /* min wall time */
"%" PRId32 ":" PERCENT_FMT "/" /* max wall time */ "%" PRId32 "." NANOSECONDS_FMT "/" /* max wall time */
"%" PRId32 ":" PERCENT_FMT "\n", /* avg wall time */ "%" PRId32 "." NANOSECONDS_FMT "\n", /* avg wall time */
the_stats.min_wall_time.tv_sec, the_stats.min_wall_time.tv_sec,
the_stats.min_wall_time.tv_nsec / NANOSECONDS_DIVIDER, the_stats.min_wall_time.tv_nsec / NANOSECONDS_DIVIDER,
the_stats.max_wall_time.tv_sec, the_stats.max_wall_time.tv_sec,

View File

@@ -42,18 +42,20 @@ void _Timespec_Divide(
right = rhs->tv_sec * (uint64_t)TOD_NANOSECONDS_PER_SECOND; right = rhs->tv_sec * (uint64_t)TOD_NANOSECONDS_PER_SECOND;
right += rhs->tv_nsec; right += rhs->tv_nsec;
if ( rhs == 0 ) { if ( right == 0 ) {
*ival_percentage = 0;
*ival_percentage = 0; *ival_percentage = 0;
*fval_percentage = 0;
return; return;
} }
/* /*
* Put it back in the timespec result * Put it back in the timespec result.
*
* TODO: Rounding on the last digit of the fval.
*/ */
answer = (left * 100000) / right; answer = (left * 100000) / right;
*fval_percentage = answer % 1000;
*ival_percentage = answer / 1000; *ival_percentage = answer / 1000;
*fval_percentage = answer % 1000;
} }