[a6500136] | 1 | /** |
---|
| 2 | * @file |
---|
[e1bce86] | 3 | * |
---|
[a6500136] | 4 | * @brief RTEMS Report Rate Monotonic Statistics |
---|
| 5 | * @ingroup ClassicRateMon |
---|
| 6 | */ |
---|
| 7 | |
---|
| 8 | /* |
---|
[5290c5a] | 9 | * COPYRIGHT (c) 1989-2010. |
---|
[e1bce86] | 10 | * On-Line Applications Research Corporation (OAR). |
---|
| 11 | * |
---|
| 12 | * The license and distribution terms for this file may be |
---|
| 13 | * found in the file LICENSE in this distribution or at |
---|
[c499856] | 14 | * http://www.rtems.org/license/LICENSE. |
---|
[e1bce86] | 15 | */ |
---|
| 16 | |
---|
| 17 | #ifdef HAVE_CONFIG_H |
---|
| 18 | #include "config.h" |
---|
| 19 | #endif |
---|
| 20 | |
---|
[ecdcf01] | 21 | #include <rtems/rtems/ratemonimpl.h> |
---|
| 22 | #include <rtems/rtems/object.h> |
---|
[e1bce86] | 23 | |
---|
[ecdcf01] | 24 | #include <inttypes.h> |
---|
[e1bce86] | 25 | |
---|
[e6b31b27] | 26 | /* We print to 1/10's of milliseconds */ |
---|
| 27 | #define NANOSECONDS_DIVIDER 1000 |
---|
| 28 | #define PERCENT_FMT "%04" PRId32 |
---|
| 29 | #define NANOSECONDS_FMT "%06" PRId32 |
---|
[c3330a8] | 30 | |
---|
[90a5d194] | 31 | void rtems_rate_monotonic_report_statistics_with_plugin( |
---|
| 32 | void *context, |
---|
| 33 | rtems_printk_plugin_t print |
---|
| 34 | ) |
---|
[e1bce86] | 35 | { |
---|
| 36 | rtems_status_code status; |
---|
| 37 | rtems_id id; |
---|
| 38 | rtems_rate_monotonic_period_statistics the_stats; |
---|
| 39 | rtems_rate_monotonic_period_status the_status; |
---|
| 40 | char name[5]; |
---|
| 41 | |
---|
[90a5d194] | 42 | if ( !print ) |
---|
| 43 | return; |
---|
| 44 | |
---|
| 45 | (*print)( context, "Period information by period\n" ); |
---|
[e6b31b27] | 46 | (*print)( context, "--- CPU times are in seconds ---\n" ); |
---|
| 47 | (*print)( context, "--- Wall times are in seconds ---\n" ); |
---|
[c3330a8] | 48 | /* |
---|
| 49 | Layout by columns -- in memory of Hollerith :) |
---|
| 50 | |
---|
| 51 | 1234567890123456789012345678901234567890123456789012345678901234567890123456789\ |
---|
| 52 | ID OWNER COUNT MISSED X |
---|
| 53 | ididididid NNNN ccccc mmmmmm X |
---|
| 54 | |
---|
| 55 | Uncomment the following if you are tinkering with the formatting. |
---|
| 56 | Be sure to test the various cases. |
---|
[90a5d194] | 57 | (*print)( context,"\ |
---|
[c3330a8] | 58 | 1234567890123456789012345678901234567890123456789012345678901234567890123456789\ |
---|
| 59 | \n"); |
---|
[b0ac06f8] | 60 | */ |
---|
[e6b31b27] | 61 | (*print)( context, |
---|
| 62 | " ID OWNER COUNT MISSED " |
---|
| 63 | " CPU TIME WALL TIME\n" |
---|
| 64 | " " |
---|
| 65 | " MIN/MAX/AVG MIN/MAX/AVG\n" |
---|
[b0ac06f8] | 66 | ); |
---|
[e1bce86] | 67 | |
---|
| 68 | /* |
---|
| 69 | * Cycle through all possible ids and try to report on each one. If it |
---|
| 70 | * is a period that is inactive, we just get an error back. No big deal. |
---|
| 71 | */ |
---|
| 72 | for ( id=_Rate_monotonic_Information.minimum_id ; |
---|
| 73 | id <= _Rate_monotonic_Information.maximum_id ; |
---|
| 74 | id++ ) { |
---|
| 75 | status = rtems_rate_monotonic_get_statistics( id, &the_stats ); |
---|
| 76 | if ( status != RTEMS_SUCCESSFUL ) |
---|
| 77 | continue; |
---|
[05c1886] | 78 | |
---|
[e1bce86] | 79 | /* If the above passed, so should this but check it anyway */ |
---|
[115fb76] | 80 | #if defined(RTEMS_DEBUG) |
---|
[5290c5a] | 81 | status = rtems_rate_monotonic_get_status( id, &the_status ); |
---|
[115fb76] | 82 | if ( status != RTEMS_SUCCESSFUL ) |
---|
| 83 | continue; |
---|
[5290c5a] | 84 | #else |
---|
| 85 | (void) rtems_rate_monotonic_get_status( id, &the_status ); |
---|
[115fb76] | 86 | #endif |
---|
[e1bce86] | 87 | |
---|
[bbb96ceb] | 88 | rtems_object_get_name( the_status.owner, sizeof(name), name ); |
---|
[e1bce86] | 89 | |
---|
[c3330a8] | 90 | /* |
---|
[05c1886] | 91 | * Print part of report line that is not dependent on granularity |
---|
[c3330a8] | 92 | */ |
---|
[90a5d194] | 93 | (*print)( context, |
---|
[c3330a8] | 94 | "0x%08" PRIx32 " %4s %5" PRId32 " %6" PRId32 " ", |
---|
[e1bce86] | 95 | id, name, |
---|
[c3330a8] | 96 | the_stats.count, the_stats.missed_count |
---|
[e1bce86] | 97 | ); |
---|
[c3330a8] | 98 | |
---|
[b0ac06f8] | 99 | /* |
---|
| 100 | * If the count is zero, don't print statistics |
---|
| 101 | */ |
---|
| 102 | if (the_stats.count == 0) { |
---|
| 103 | (*print)( context, "\n" ); |
---|
| 104 | continue; |
---|
| 105 | } |
---|
| 106 | |
---|
[c3330a8] | 107 | /* |
---|
| 108 | * print CPU Usage part of statistics |
---|
| 109 | */ |
---|
| 110 | { |
---|
[9dc2c8d] | 111 | struct timespec cpu_average; |
---|
| 112 | struct timespec *min_cpu = &the_stats.min_cpu_time; |
---|
| 113 | struct timespec *max_cpu = &the_stats.max_cpu_time; |
---|
| 114 | struct timespec *total_cpu = &the_stats.total_cpu_time; |
---|
[c3330a8] | 115 | |
---|
[9dc2c8d] | 116 | _Timespec_Divide_by_integer( total_cpu, the_stats.count, &cpu_average ); |
---|
[90a5d194] | 117 | (*print)( context, |
---|
[b0ac06f8] | 118 | "%" PRId32 "." NANOSECONDS_FMT "/" /* min cpu time */ |
---|
| 119 | "%" PRId32 "." NANOSECONDS_FMT "/" /* max cpu time */ |
---|
| 120 | "%" PRId32 "." NANOSECONDS_FMT " ", /* avg cpu time */ |
---|
[9dc2c8d] | 121 | _Timespec_Get_seconds( min_cpu ), |
---|
| 122 | _Timespec_Get_nanoseconds( min_cpu ) / NANOSECONDS_DIVIDER, |
---|
| 123 | _Timespec_Get_seconds( max_cpu ), |
---|
| 124 | _Timespec_Get_nanoseconds( max_cpu ) / NANOSECONDS_DIVIDER, |
---|
| 125 | _Timespec_Get_seconds( &cpu_average ), |
---|
| 126 | _Timespec_Get_nanoseconds( &cpu_average ) / NANOSECONDS_DIVIDER |
---|
[c3330a8] | 127 | ); |
---|
| 128 | } |
---|
| 129 | |
---|
| 130 | /* |
---|
[bbb96ceb] | 131 | * print wall time part of statistics |
---|
[c3330a8] | 132 | */ |
---|
| 133 | { |
---|
[9dc2c8d] | 134 | struct timespec wall_average; |
---|
| 135 | struct timespec *min_wall = &the_stats.min_wall_time; |
---|
| 136 | struct timespec *max_wall = &the_stats.max_wall_time; |
---|
| 137 | struct timespec *total_wall = &the_stats.total_wall_time; |
---|
[c16bcc0] | 138 | |
---|
[9dc2c8d] | 139 | _Timespec_Divide_by_integer(total_wall, the_stats.count, &wall_average); |
---|
[90a5d194] | 140 | (*print)( context, |
---|
[b0ac06f8] | 141 | "%" PRId32 "." NANOSECONDS_FMT "/" /* min wall time */ |
---|
| 142 | "%" PRId32 "." NANOSECONDS_FMT "/" /* max wall time */ |
---|
| 143 | "%" PRId32 "." NANOSECONDS_FMT "\n", /* avg wall time */ |
---|
[9dc2c8d] | 144 | _Timespec_Get_seconds( min_wall ), |
---|
| 145 | _Timespec_Get_nanoseconds( min_wall ) / NANOSECONDS_DIVIDER, |
---|
| 146 | _Timespec_Get_seconds( max_wall ), |
---|
| 147 | _Timespec_Get_nanoseconds( max_wall ) / NANOSECONDS_DIVIDER, |
---|
| 148 | _Timespec_Get_seconds( &wall_average ), |
---|
| 149 | _Timespec_Get_nanoseconds( &wall_average ) / NANOSECONDS_DIVIDER |
---|
[c3330a8] | 150 | ); |
---|
| 151 | } |
---|
[e1bce86] | 152 | } |
---|
| 153 | } |
---|
[90a5d194] | 154 | |
---|
| 155 | void rtems_rate_monotonic_report_statistics( void ) |
---|
| 156 | { |
---|
| 157 | rtems_rate_monotonic_report_statistics_with_plugin( NULL, printk_plugin ); |
---|
| 158 | } |
---|