source: rtems/cpukit/rtems/src/ratemonreportstatistics.c @ e6b31b27

4.11
Last change on this file since e6b31b27 was e6b31b27, checked in by Joel Sherrill <joel.sherrill@…>, on May 27, 2015 at 3:13:58 PM

Remove use ticks for statistics configure option.

This was obsolete and broken based upon recent time keeping changes.

Thie build option was previously enabled by adding
USE_TICKS_FOR_STATISTICS=1 to the configure command line.

This propagated into the code as preprocessor conditionals
using the RTEMS_USE_TICKS_FOR_STATISTICS conditional.

  • 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
24#include <inttypes.h>
25
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
30
31void rtems_rate_monotonic_report_statistics_with_plugin(
32  void                  *context,
33  rtems_printk_plugin_t  print
34)
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
42  if ( !print )
43    return;
44
45  (*print)( context, "Period information by period\n" );
46  (*print)( context, "--- CPU times are in seconds ---\n" );
47  (*print)( context, "--- Wall times are in seconds ---\n" );
48/*
49Layout by columns -- in memory of Hollerith :)
50
511234567890123456789012345678901234567890123456789012345678901234567890123456789\
52   ID     OWNER COUNT MISSED X
53ididididid NNNN ccccc mmmmmm X
54
55  Uncomment the following if you are tinkering with the formatting.
56  Be sure to test the various cases.
57  (*print)( context,"\
581234567890123456789012345678901234567890123456789012345678901234567890123456789\
59\n");
60*/
61  (*print)( context,
62      "   ID     OWNER COUNT MISSED     "
63      "     CPU TIME                  WALL TIME\n"
64      "                               "
65      "     MIN/MAX/AVG                MIN/MAX/AVG\n"
66  );
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;
78
79    /* If the above passed, so should this but check it anyway */
80    #if defined(RTEMS_DEBUG)
81      status = rtems_rate_monotonic_get_status( id, &the_status );
82      if ( status != RTEMS_SUCCESSFUL )
83        continue;
84    #else
85      (void) rtems_rate_monotonic_get_status( id, &the_status );
86    #endif
87
88    rtems_object_get_name( the_status.owner, sizeof(name), name );
89
90    /*
91     *  Print part of report line that is not dependent on granularity
92     */
93    (*print)( context,
94      "0x%08" PRIx32 " %4s %5" PRId32 " %6" PRId32 " ",
95      id, name,
96      the_stats.count, the_stats.missed_count
97    );
98
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
107    /*
108     *  print CPU Usage part of statistics
109     */
110    {
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;
115
116      _Timespec_Divide_by_integer( total_cpu, the_stats.count, &cpu_average );
117      (*print)( context,
118        "%" PRId32 "."  NANOSECONDS_FMT "/"        /* min cpu time */
119        "%" PRId32 "."  NANOSECONDS_FMT "/"        /* max cpu time */
120        "%" PRId32 "."  NANOSECONDS_FMT " ",       /* avg cpu time */
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
127       );
128    }
129
130    /*
131     *  print wall time part of statistics
132     */
133    {
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;
138
139      _Timespec_Divide_by_integer(total_wall, the_stats.count, &wall_average);
140      (*print)( context,
141        "%" PRId32 "." NANOSECONDS_FMT "/"        /* min wall time */
142        "%" PRId32 "." NANOSECONDS_FMT "/"        /* max wall time */
143        "%" PRId32 "." NANOSECONDS_FMT "\n",      /* avg wall time */
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
150      );
151    }
152  }
153}
154
155void rtems_rate_monotonic_report_statistics( void )
156{
157  rtems_rate_monotonic_report_statistics_with_plugin( NULL, printk_plugin );
158}
Note: See TracBrowser for help on using the repository browser.