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

4.104.114.84.95
Last change on this file since e1bce86 was e1bce86, checked in by Joel Sherrill <joel.sherrill@…>, on May 15, 2007 at 8:16:16 PM

2007-05-15 Joel Sherrill <joel.sherrill@…>

  • Makefile.am, preinstall.am, libmisc/Makefile.am, rtems/Makefile.am, rtems/include/rtems.h, rtems/include/rtems/rtems/ratemon.h, rtems/inline/rtems/rtems/ratemon.inl, rtems/src/ratemoncancel.c, rtems/src/ratemoncreate.c, rtems/src/ratemondelete.c, rtems/src/ratemongetstatus.c, rtems/src/ratemonident.c, rtems/src/ratemonperiod.c, rtems/src/ratemontimeout.c, score/Makefile.am, score/include/rtems/score/object.h, score/src/threadhandler.c, wrapup/Makefile.am: Integrate Rate Monotonic Statistics and Period Usage into Rate Monotonic Manager. Added the following directives: rtems_rate_monotonic_get_statistics, rtems_rate_monotonic_reset_statistics, rtems_rate_montonic_reset_all_statistics, rtems_rate_montonic_report_statistics, and rtems_object_get_name. Obsoleted the rtems/rtmonuse.h file as a public interface.
  • rtems/src/ratemongetstatistics.c, rtems/src/ratemonreportstatistics.c, rtems/src/ratemonresetall.c, rtems/src/ratemonresetstatistics.c, rtems/src/rtemsobjectgetname.c, score/src/objectgetnameasstring.c: New files.
  • libmisc/rtmonuse/rtmonuse.c, libmisc/rtmonuse/rtmonuse.h: Removed.
  • Property mode set to 100644
File size: 2.8 KB
Line 
1/*
2 *  Rate Monotonic Manager -- Report Statistics for All Periods
3 *
4 *  COPYRIGHT (c) 1989-2007.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#ifdef HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <rtems.h>
19#include <stdlib.h>
20#include <ctype.h>
21#include <inttypes.h>
22
23#include <rtems/bspIo.h>
24
25/*
26 *  This directive allows a thread to print the statistics information
27 *  on ALL period instances which have non-zero counts using printk.
28 *
29 *  The implementation of this directive straddles the fence between
30 *  inside and outside of RTEMS.  It is presented as part of the Manager
31 *  but actually uses other services of the Manager.
32 */
33void rtems_rate_montonic_report_statistics( void )
34{
35  rtems_status_code                      status;
36  rtems_id                               id;
37  rtems_rate_monotonic_period_statistics the_stats;
38  rtems_rate_monotonic_period_status     the_status;
39  char                                   name[5];
40  uint32_t                               ival_cpu, fval_cpu;
41  uint32_t                               ival_wall, fval_wall;
42
43  printk(
44    "Period information by period\n"
45   "   ID      OWNER   PERIODS  MISSED    CPU TIME    WALL TIME\n"
46  );
47
48  /*
49   * Cycle through all possible ids and try to report on each one.  If it
50   * is a period that is inactive, we just get an error back.  No big deal.
51   */
52  for ( id=_Rate_monotonic_Information.minimum_id ;
53        id <= _Rate_monotonic_Information.maximum_id ;
54        id++ ) {
55    status = rtems_rate_monotonic_get_statistics( id, &the_stats );
56    if ( status != RTEMS_SUCCESSFUL )
57      continue;
58   
59    /* If the above passed, so should this but check it anyway */
60    status = rtems_rate_monotonic_get_status( id, &the_status );
61    if ( status != RTEMS_SUCCESSFUL )
62      continue;
63   
64    if ( the_stats.count == 0 )
65      continue;
66
67    ival_cpu = the_stats.total_cpu_time * 100 / the_stats.count;
68
69    name[ 0 ] = '\0';
70
71    if ( the_status.owner ) {
72      rtems_object_get_name( the_status.owner, sizeof(name), name );
73    }
74
75    fval_cpu = ival_cpu % 100;
76    ival_cpu /= 100;
77    ival_wall = the_stats.total_wall_time * 100 / the_stats.count;
78    fval_wall = ival_wall % 100;
79    ival_wall /= 100;
80    printk(
81      "0x%08" PRIx32 "  %4s   %6" PRId32 "   %3" PRId32 "       "
82         "%" PRId32 "/%" PRId32 "/%" PRId32 ".%02" PRId32 "    "
83         "%" PRId32 "/%" PRId32 "/%" PRId32 ".%02" PRId32 "\n",
84      id, name,
85      the_stats.count, the_stats.missed_count,
86      the_stats.min_cpu_time, the_stats.max_cpu_time, ival_cpu, fval_cpu,
87      the_stats.min_wall_time, the_stats.max_wall_time, ival_wall, fval_wall
88    );
89  }
90}
Note: See TracBrowser for help on using the repository browser.