source: rtems/cpukit/rtems/src/ratemonreportstatistics.c @ 3899bc1a

5
Last change on this file since 3899bc1a was 3899bc1a, checked in by Sebastian Huber <sebastian.huber@…>, on 11/24/18 at 10:51:28

score: Optimize object lookup

Use the maximum ID for the ID to object translation. Using the maximum
ID gets rid of an additional load from the object information in
_Objects_Get(). In addition, object lookups fail for every ID in case
the object information is cleared to zero. This makes it a bit more
robust during system startup (see new tests in spconfig02).

The local table no longer needs a NULL pointer entry at array index
zero. Adjust all the object iteration loops accordingly.

Remove Objects_Information::minimum_id since it contains only redundant
information. Add _Objects_Get_minimum_id() to get the minimum ID.

Update #3621.

  • Property mode set to 100644
File size: 5.1 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                               maximum_id;
39  rtems_id                               id;
40  rtems_rate_monotonic_period_statistics the_stats;
41  rtems_rate_monotonic_period_status     the_status;
42  char                                   name[5];
43
44  rtems_printf( printer, "Period information by period\n" );
45  rtems_printf( printer, "--- CPU times are in seconds ---\n" );
46  rtems_printf( printer, "--- Wall times are in seconds ---\n" );
47/*
48Layout by columns -- in memory of Hollerith :)
49
501234567890123456789012345678901234567890123456789012345678901234567890123456789\
51   ID     OWNER COUNT MISSED X
52ididididid NNNN ccccc mmmmmm X
53
54  Uncomment the following if you are tinkering with the formatting.
55  Be sure to test the various cases.
56  (*print)( context,"\
571234567890123456789012345678901234567890123456789012345678901234567890123456789\
58\n");
59*/
60  rtems_printf( printer,
61      "   ID     OWNER COUNT MISSED     "
62      "     CPU TIME                  WALL TIME\n"
63      "                               "
64      "     MIN/MAX/AVG                MIN/MAX/AVG\n"
65  );
66
67  /*
68   * Cycle through all possible ids and try to report on each one.  If it
69   * is a period that is inactive, we just get an error back.  No big deal.
70   */
71  maximum_id = _Rate_monotonic_Information.maximum_id;
72  for (
73    id = _Objects_Get_minimum_id( maximum_id ) ;
74    id <= maximum_id ;
75    ++id
76  ) {
77    status = rtems_rate_monotonic_get_statistics( id, &the_stats );
78    if ( status != RTEMS_SUCCESSFUL )
79      continue;
80
81    /* If the above passed, so should this but check it anyway */
82    #if defined(RTEMS_DEBUG)
83      status = rtems_rate_monotonic_get_status( id, &the_status );
84      if ( status != RTEMS_SUCCESSFUL )
85        continue;
86    #else
87      (void) rtems_rate_monotonic_get_status( id, &the_status );
88    #endif
89
90    rtems_object_get_name( the_status.owner, sizeof(name), name );
91
92    /*
93     *  Print part of report line that is not dependent on granularity
94     */
95    rtems_printf( printer,
96      "0x%08" PRIx32 " %4s %5" PRId32 " %6" PRId32 " ",
97      id, name,
98      the_stats.count, the_stats.missed_count
99    );
100
101    /*
102     *  If the count is zero, don't print statistics
103     */
104    if (the_stats.count == 0) {
105      rtems_printf( printer, "\n" );
106      continue;
107    }
108
109    /*
110     *  print CPU Usage part of statistics
111     */
112    {
113      struct timespec  cpu_average;
114      struct timespec *min_cpu = &the_stats.min_cpu_time;
115      struct timespec *max_cpu = &the_stats.max_cpu_time;
116      struct timespec *total_cpu = &the_stats.total_cpu_time;
117
118      _Timespec_Divide_by_integer( total_cpu, the_stats.count, &cpu_average );
119      rtems_printf( printer,
120        "%" PRIdtime_t "."  NANOSECONDS_FMT "/"        /* min cpu time */
121        "%" PRIdtime_t "."  NANOSECONDS_FMT "/"        /* max cpu time */
122        "%" PRIdtime_t "."  NANOSECONDS_FMT " ",       /* avg cpu time */
123        _Timespec_Get_seconds( min_cpu ),
124          _Timespec_Get_nanoseconds( min_cpu ) / NANOSECONDS_DIVIDER,
125        _Timespec_Get_seconds( max_cpu ),
126          _Timespec_Get_nanoseconds( max_cpu ) / NANOSECONDS_DIVIDER,
127        _Timespec_Get_seconds( &cpu_average ),
128          _Timespec_Get_nanoseconds( &cpu_average ) / NANOSECONDS_DIVIDER
129       );
130    }
131
132    /*
133     *  print wall time part of statistics
134     */
135    {
136      struct timespec  wall_average;
137      struct timespec *min_wall = &the_stats.min_wall_time;
138      struct timespec *max_wall = &the_stats.max_wall_time;
139      struct timespec *total_wall = &the_stats.total_wall_time;
140
141      _Timespec_Divide_by_integer(total_wall, the_stats.count, &wall_average);
142      rtems_printf( printer,
143        "%" PRIdtime_t "." NANOSECONDS_FMT "/"        /* min wall time */
144        "%" PRIdtime_t "." NANOSECONDS_FMT "/"        /* max wall time */
145        "%" PRIdtime_t "." NANOSECONDS_FMT "\n",      /* avg wall time */
146        _Timespec_Get_seconds( min_wall ),
147          _Timespec_Get_nanoseconds( min_wall ) / NANOSECONDS_DIVIDER,
148        _Timespec_Get_seconds( max_wall ),
149          _Timespec_Get_nanoseconds( max_wall ) / NANOSECONDS_DIVIDER,
150        _Timespec_Get_seconds( &wall_average ),
151          _Timespec_Get_nanoseconds( &wall_average ) / NANOSECONDS_DIVIDER
152      );
153    }
154  }
155}
156
157void rtems_rate_monotonic_report_statistics( void )
158{
159  rtems_printer printer;
160  rtems_print_printer_printk( &printer );
161  rtems_rate_monotonic_report_statistics_with_plugin( &printer );
162}
Note: See TracBrowser for help on using the repository browser.