source: rtems/cpukit/rtems/src/ratemonreportstatistics.c @ 6b5f22dc

Last change on this file since 6b5f22dc was 6b5f22dc, checked in by Sebastian Huber <sebastian.huber@…>, on 11/26/20 at 10:45:47

rtems: Canonicalize Doxygen @file comments

Use common phrases for the file brief descriptions.

Update #3706.

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