source: rtems/cpukit/rtems/src/ratemonreportstatistics.c @ 66cb142

Last change on this file since 66cb142 was 900fda45, checked in by Sebastian Huber <sebastian.huber@…>, on Oct 6, 2017 at 7:42:32 AM

rtems: Fix format warnings

Update #3111.

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