Changeset e6b31b27 in rtems


Ignore:
Timestamp:
May 27, 2015, 3:13:58 PM (4 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.11, master
Children:
e0938c2
Parents:
80fca28
git-author:
Joel Sherrill <joel.sherrill@…> (05/27/15 15:13:58)
git-committer:
Joel Sherrill <joel.sherrill@…> (06/15/15 18:20:17)
Message:

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.

Files:
19 edited

Legend:

Unmodified
Added
Removed
  • cpukit/configure.ac

    r80fca28 re6b31b27  
    240240  ["]_RTEMS_VERSION["],
    241241  [RTEMS version string])
    242 
    243 RTEMS_CPUOPT([__RTEMS_USE_TICKS_FOR_STATISTICS__],
    244   [test x"${USE_TICKS_FOR_STATISTICS}" = x"1"],
    245   [1],
    246   [disable nanosecond granularity for statistics])
    247242
    248243## Header file differences that need to be known in .h after install
  • cpukit/libcsupport/src/__times.c

    r80fca28 re6b31b27  
    3232#include <rtems/seterr.h>
    3333#include <rtems/score/todimpl.h>
    34 #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    35   #include <rtems/score/timestamp.h>
    36 #endif
     34#include <rtems/score/timestamp.h>
    3735#include <rtems/score/threadimpl.h>
    3836
     
    6462   *  this thread.
    6563   */
     64  {
     65    Timestamp_Control  per_tick;
     66    uint32_t           ticks_of_executing;
     67    uint32_t           fractional_ticks;
     68    Per_CPU_Control   *cpu_self;
    6669
    67   #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    68     {
    69       Timestamp_Control  per_tick;
    70       uint32_t           ticks_of_executing;
    71       uint32_t           fractional_ticks;
    72       Per_CPU_Control   *cpu_self;
     70    _Timestamp_Set(
     71      &per_tick,
     72      rtems_configuration_get_microseconds_per_tick() /
     73          TOD_MICROSECONDS_PER_SECOND,
     74      (rtems_configuration_get_nanoseconds_per_tick() %
     75          TOD_NANOSECONDS_PER_SECOND)
     76    );
    7377
    74       _Timestamp_Set(
    75         &per_tick,
    76         rtems_configuration_get_microseconds_per_tick() /
    77             TOD_MICROSECONDS_PER_SECOND,
    78         (rtems_configuration_get_nanoseconds_per_tick() %
    79             TOD_NANOSECONDS_PER_SECOND)
    80       );
    81 
    82       cpu_self = _Thread_Dispatch_disable();
    83       executing = _Thread_Executing;
    84       _Thread_Update_cpu_time_used(
    85         executing,
    86         &_Thread_Time_of_last_context_switch
    87       );
    88       _Timestamp_Divide(
    89         &executing->cpu_time_used,
    90         &per_tick,
    91         &ticks_of_executing,
    92         &fractional_ticks
    93       );
    94       _Thread_Dispatch_enable( cpu_self );
    95       ptms->tms_utime = ticks_of_executing * us_per_tick;
    96     }
    97   #else
    98     executing = _Thread_Get_executing();
    99     ptms->tms_utime  = executing->cpu_time_used * us_per_tick;
    100   #endif
     78    cpu_self = _Thread_Dispatch_disable();
     79    executing = _Thread_Executing;
     80    _Thread_Update_cpu_time_used(
     81      executing,
     82      &_Thread_Time_of_last_context_switch
     83    );
     84    _Timestamp_Divide(
     85      &executing->cpu_time_used,
     86      &per_tick,
     87      &ticks_of_executing,
     88      &fractional_ticks
     89    );
     90    _Thread_Dispatch_enable( cpu_self );
     91    ptms->tms_utime = ticks_of_executing * us_per_tick;
     92  }
    10193  ptms->tms_stime  = ticks * us_per_tick;
    10294  ptms->tms_cutime = 0;
  • cpukit/libmisc/cpuuse/cpuusagedata.c

    r80fca28 re6b31b27  
    2323#include <rtems/cpuuse.h>
    2424
    25 #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    26   Timestamp_Control  CPU_usage_Uptime_at_last_reset;
    27 #else
    28   uint32_t           CPU_usage_Ticks_at_last_reset;
    29 #endif
     25Timestamp_Control  CPU_usage_Uptime_at_last_reset;
  • cpukit/libmisc/cpuuse/cpuusagereport.c

    r80fca28 re6b31b27  
    4545  char                 name[13];
    4646  uint32_t             ival, fval;
    47   #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    48     Timestamp_Control  uptime, total, ran, uptime_at_last_reset;
    49     uint32_t seconds, nanoseconds;
    50   #else
    51     uint32_t           total_units = 0;
    52   #endif
     47  Timestamp_Control  uptime, total, ran, uptime_at_last_reset;
     48  uint32_t seconds, nanoseconds;
    5349
    5450  if ( !print )
     
    6056   *  guideline as to what each number means proportionally.
    6157   */
    62   #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    63     _Timestamp_Set_to_zero( &total );
    64     uptime_at_last_reset = CPU_usage_Uptime_at_last_reset;
    65   #else
    66     for ( api_index = 1 ; api_index <= OBJECTS_APIS_LAST ; api_index++ ) {
    67       #if !defined(RTEMS_POSIX_API) || defined(RTEMS_DEBUG)
    68         if ( !_Objects_Information_table[ api_index ] )
    69           continue;
    70       #endif
    71 
    72       information = _Objects_Information_table[ api_index ][ 1 ];
    73       if ( information ) {
    74         for ( i=1 ; i <= information->maximum ; i++ ) {
    75           the_thread = (Thread_Control *)information->local_table[ i ];
    76 
    77           if ( the_thread )
    78             total_units += the_thread->cpu_time_used;
    79         }
    80       }
    81     }
    82   #endif
     58  _Timestamp_Set_to_zero( &total );
     59  uptime_at_last_reset = CPU_usage_Uptime_at_last_reset;
    8360
    8461  (*print)(
     
    8764     "                              CPU USAGE BY THREAD\n"
    8865     "------------+----------------------------------------+---------------+---------\n"
    89      #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    90        " ID         | NAME                                   | SECONDS       | PERCENT\n"
    91      #else
    92        " ID         | NAME                                   | TICKS         | PERCENT\n"
    93      #endif
     66     " ID         | NAME                                   | SECONDS       | PERCENT\n"
    9467     "------------+----------------------------------------+---------------+---------\n"
    9568  );
     
    11891        );
    11992
    120         #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    12193        {
    12294          Timestamp_Control last;
     
    151123          );
    152124        }
    153         #else
    154          if (total_units) {
    155             uint64_t ival_64;
    156 
    157             ival_64 = the_thread->cpu_time_used;
    158             ival_64 *= 100000;
    159             ival = ival_64 / total_units;
    160           } else {
    161             ival = 0;
    162           }
    163 
    164           fval = ival % 1000;
    165           ival /= 1000;
    166           (*print)( context,
    167             "%14" PRIu32 " |%4" PRIu32 ".%03" PRIu32 "\n",
    168             the_thread->cpu_time_used,
    169             ival,
    170             fval
    171           );
    172         #endif
    173125      }
    174126    }
    175127  }
    176128
    177   #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    178     seconds = _Timestamp_Get_seconds( &total );
    179     nanoseconds = _Timestamp_Get_nanoseconds( &total ) /
    180       TOD_NANOSECONDS_PER_MICROSECOND;
    181     (*print)(
    182        context,
    183        "------------+----------------------------------------+---------------+---------\n"
    184        " TIME SINCE LAST CPU USAGE RESET IN SECONDS:                    %7" PRIu32 ".%06" PRIu32 "\n"
    185        "-------------------------------------------------------------------------------\n",
    186        seconds, nanoseconds
    187     );
    188   #else
    189     (*print)(
    190        context,
    191        "------------+----------------------------------------+---------------+---------\n"
    192        " TICKS SINCE LAST SYSTEM RESET:                                 %14" PRIu32 "\n"
    193        " TOTAL UNITS:                                                   %14" PRIu32 "\n"
    194        "-------------------------------------------------------------------------------\n",
    195        _Watchdog_Ticks_since_boot - CPU_usage_Ticks_at_last_reset,
    196        total_units
    197     );
    198   #endif
     129  seconds = _Timestamp_Get_seconds( &total );
     130  nanoseconds = _Timestamp_Get_nanoseconds( &total ) /
     131    TOD_NANOSECONDS_PER_MICROSECOND;
     132  (*print)(
     133     context,
     134     "------------+----------------------------------------+---------------+---------\n"
     135     " TIME SINCE LAST CPU USAGE RESET IN SECONDS:                    %7" PRIu32 ".%06" PRIu32 "\n"
     136     "-------------------------------------------------------------------------------\n",
     137     seconds, nanoseconds
     138  );
    199139}
    200140
  • cpukit/libmisc/cpuuse/cpuusagereset.c

    r80fca28 re6b31b27  
    2828)
    2929{
    30   #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    31     _Timestamp_Set_to_zero( &the_thread->cpu_time_used );
    32   #else
    33     the_thread->cpu_time_used = 0;
    34   #endif
     30  _Timestamp_Set_to_zero( &the_thread->cpu_time_used );
    3531}
    3632
     
    4036void rtems_cpu_usage_reset( void )
    4137{
    42   #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    43     uint32_t cpu_count;
    44     uint32_t cpu_index;
     38  uint32_t cpu_count;
     39  uint32_t cpu_index;
    4540
    46     _TOD_Get_uptime( &CPU_usage_Uptime_at_last_reset );
     41  _TOD_Get_uptime( &CPU_usage_Uptime_at_last_reset );
    4742
    48     cpu_count = rtems_get_processor_count();
    49     for ( cpu_index = 0 ; cpu_index < cpu_count ; ++cpu_index ) {
    50       Per_CPU_Control *cpu = _Per_CPU_Get_by_index( cpu_index );
     43  cpu_count = rtems_get_processor_count();
     44  for ( cpu_index = 0 ; cpu_index < cpu_count ; ++cpu_index ) {
     45    Per_CPU_Control *cpu = _Per_CPU_Get_by_index( cpu_index );
    5146
    52       cpu->time_of_last_context_switch = CPU_usage_Uptime_at_last_reset;
    53     }
    54   #else
    55     CPU_usage_Ticks_at_last_reset = _Watchdog_Ticks_since_boot;
    56   #endif
     47    cpu->time_of_last_context_switch = CPU_usage_Uptime_at_last_reset;
     48  }
    5749
    5850  rtems_iterate_over_all_threads(CPU_usage_Per_thread_handler);
  • cpukit/libmisc/cpuuse/cpuusagetop.c

    r80fca28 re6b31b27  
    145145}
    146146
    147 #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    148   #define CPU_usage_Equal_to( _lhs, _rhs ) \
    149           _Timestamp_Equal_to( _lhs, _rhs )
    150 #else
    151   #define CPU_usage_Equal_to( _lhs, _rhs ) \
    152           equal_to_uint32_t( _lhs, _rhs )
    153 #endif
    154 
    155 #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    156   #define CPU_usage_Set_to_zero( _time ) \
    157          _Timestamp_Set_to_zero( _time )
    158 #else
    159   #define CPU_usage_Set_to_zero( _time ) \
    160        do { \
    161          *_time = 0; \
    162        } while (0)
    163 #endif
    164 
    165 #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    166   #define CPU_usage_Less_than( _lhs, _rhs ) \
    167         _Timestamp_Less_than( _lhs, _rhs )
    168 #else
    169   #define CPU_usage_Less_than( _lhs, _rhs ) \
    170          less_than_uint32_t( _lhs, _rhs )
    171 #endif
     147#define CPU_usage_Equal_to( _lhs, _rhs ) \
     148        _Timestamp_Equal_to( _lhs, _rhs )
     149
     150#define CPU_usage_Set_to_zero( _time ) \
     151       _Timestamp_Set_to_zero( _time )
     152
     153#define CPU_usage_Less_than( _lhs, _rhs ) \
     154      _Timestamp_Less_than( _lhs, _rhs )
    172155
    173156static void
     
    582565)
    583566{
    584 #ifdef __RTEMS_USE_TICKS_FOR_STATISTICS__
    585   if ( !print )
    586     return;
    587   (*print)(context, "error: tick kernels not supported\n");
    588 #else
    589567  rtems_status_code      sc;
    590568  rtems_task_priority    priority;
     
    715693    }
    716694  }
    717 #endif
    718695}
    719696
  • cpukit/libmisc/cpuuse/cpuuse.h

    r80fca28 re6b31b27  
    2626#include <rtems/bspIo.h>
    2727
    28 #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    29   #include <rtems/score/timestamp.h>
    30 #endif
     28#include <rtems/score/timestamp.h>
    3129
    3230/**
     
    4038#endif
    4139
    42 #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    43   extern Timestamp_Control  CPU_usage_Uptime_at_last_reset;
    44 #else
    45   extern uint32_t           CPU_usage_Ticks_at_last_reset;
    46 #endif
     40extern Timestamp_Control  CPU_usage_Uptime_at_last_reset;
    4741
    4842/*
  • cpukit/rtems/include/rtems/rtems/ratemon.h

    r80fca28 re6b31b27  
    6363 *  statistics.
    6464 */
    65 #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    66   #include <rtems/score/timespec.h>
    67 
    68   typedef struct timespec rtems_rate_monotonic_period_time_t;
    69 #else
    70   typedef uint32_t rtems_rate_monotonic_period_time_t;
    71 #endif
     65#include <rtems/score/timespec.h>
     66
     67typedef struct timespec rtems_rate_monotonic_period_time_t;
    7268
    7369/**
     
    7571 *  statistics.
    7672 */
    77 #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    78   #include <rtems/score/timestamp.h>
    79 
    80   typedef Timestamp_Control Rate_monotonic_Period_time_t;
    81 #else
    82   typedef uint32_t Rate_monotonic_Period_time_t;
    83 #endif
     73#include <rtems/score/timestamp.h>
     74
     75typedef Timestamp_Control Rate_monotonic_Period_time_t;
    8476
    8577/**
  • cpukit/rtems/include/rtems/rtems/ratemonimpl.h

    r80fca28 re6b31b27  
    202202 *  This method resets the statistics information for a period instance.
    203203 */
    204 #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    205   #define _Rate_monotonic_Reset_wall_time_statistics( _the_period ) \
    206      do { \
    207         /* set the minimums to a large value */ \
    208         _Timestamp_Set( \
    209           &(_the_period)->Statistics.min_wall_time, \
    210           0x7fffffff, \
    211           0x7fffffff \
    212         ); \
    213      } while (0)
    214 #else
    215   #define _Rate_monotonic_Reset_wall_time_statistics( _the_period ) \
    216      do { \
    217         /* set the minimum to a large value */ \
    218         (_the_period)->Statistics.min_wall_time = 0xffffffff; \
    219      } while (0)
    220 #endif
     204#define _Rate_monotonic_Reset_wall_time_statistics( _the_period ) \
     205   do { \
     206      /* set the minimums to a large value */ \
     207      _Timestamp_Set( \
     208        &(_the_period)->Statistics.min_wall_time, \
     209        0x7fffffff, \
     210        0x7fffffff \
     211      ); \
     212   } while (0)
    221213
    222214/**
     
    225217 *  This helper method resets the period CPU usage statistics structure.
    226218 */
    227 #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    228   #define _Rate_monotonic_Reset_cpu_use_statistics( _the_period ) \
    229      do { \
    230         /* set the minimums to a large value */ \
    231         _Timestamp_Set( \
    232           &(_the_period)->Statistics.min_cpu_time, \
    233           0x7fffffff, \
    234           0x7fffffff \
    235         ); \
    236      } while (0)
    237 #else
    238   #define _Rate_monotonic_Reset_cpu_use_statistics( _the_period ) \
    239      do { \
    240         /* set the minimum to a large value */ \
    241         (_the_period)->Statistics.min_cpu_time = 0xffffffff; \
    242      } while (0)
    243 #endif
     219#define _Rate_monotonic_Reset_cpu_use_statistics( _the_period ) \
     220   do { \
     221      /* set the minimums to a large value */ \
     222      _Timestamp_Set( \
     223        &(_the_period)->Statistics.min_cpu_time, \
     224        0x7fffffff, \
     225        0x7fffffff \
     226      ); \
     227   } while (0)
    244228
    245229/**
  • cpukit/rtems/include/rtems/rtems/types.h

    r80fca28 re6b31b27  
    125125 * variety of representations.
    126126 */
    127 #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    128   typedef struct timespec rtems_thread_cpu_usage_t;
    129 #else
    130   typedef uint32_t rtems_thread_cpu_usage_t;
    131 #endif
     127typedef struct timespec rtems_thread_cpu_usage_t;
    132128
    133129/**
  • cpukit/rtems/src/ratemongetstatistics.c

    r80fca28 re6b31b27  
    4747      dst->count        = src->count;
    4848      dst->missed_count = src->missed_count;
    49       #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    50         _Timestamp_To_timespec( &src->min_cpu_time,   &dst->min_cpu_time );
    51         _Timestamp_To_timespec( &src->max_cpu_time,   &dst->max_cpu_time );
    52         _Timestamp_To_timespec( &src->total_cpu_time, &dst->total_cpu_time );
    53         _Timestamp_To_timespec( &src->min_wall_time,   &dst->min_wall_time );
    54         _Timestamp_To_timespec( &src->max_wall_time,   &dst->max_wall_time );
    55         _Timestamp_To_timespec( &src->total_wall_time, &dst->total_wall_time );
    56       #else
    57         dst->min_cpu_time    = src->min_cpu_time;
    58         dst->max_cpu_time    = src->max_cpu_time;
    59         dst->total_cpu_time  = src->total_cpu_time;
    60         dst->min_wall_time   = src->min_wall_time;
    61         dst->max_wall_time   = src->max_wall_time;
    62         dst->total_wall_time = src->total_wall_time;
    63       #endif
     49      _Timestamp_To_timespec( &src->min_cpu_time,   &dst->min_cpu_time );
     50      _Timestamp_To_timespec( &src->max_cpu_time,   &dst->max_cpu_time );
     51      _Timestamp_To_timespec( &src->total_cpu_time, &dst->total_cpu_time );
     52      _Timestamp_To_timespec( &src->min_wall_time,   &dst->min_wall_time );
     53      _Timestamp_To_timespec( &src->max_wall_time,   &dst->max_wall_time );
     54      _Timestamp_To_timespec( &src->total_wall_time, &dst->total_wall_time );
    6455
    6556      _Objects_Put( &the_period->Object );
  • cpukit/rtems/src/ratemongetstatus.c

    r80fca28 re6b31b27  
    2525#include <rtems/rtems/ratemonimpl.h>
    2626#include <rtems/score/thread.h>
    27 
    28 #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    29   #include <rtems/score/timespec.h>
    30 #endif
     27#include <rtems/score/timespec.h>
    3128
    3229rtems_status_code rtems_rate_monotonic_get_status(
     
    5552       */
    5653      if ( status->state == RATE_MONOTONIC_INACTIVE ) {
    57         #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    58           _Timespec_Set_to_zero( &status->since_last_period );
    59           _Timespec_Set_to_zero( &status->executed_since_last_period );
    60         #else
    61           status->since_last_period = 0;
    62           status->executed_since_last_period = 0;
    63         #endif
    64 
     54        _Timespec_Set_to_zero( &status->since_last_period );
     55        _Timespec_Set_to_zero( &status->executed_since_last_period );
    6556      } else {
    6657
     
    7768        }
    7869
    79         #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    80           _Timestamp_To_timespec(
    81             &since_last_period, &status->since_last_period
    82           );
    83           _Timestamp_To_timespec(
    84             &executed, &status->executed_since_last_period
    85           );
    86         #else
    87           status->since_last_period = since_last_period;
    88           status->executed_since_last_period = executed;
    89         #endif
     70        _Timestamp_To_timespec(
     71          &since_last_period, &status->since_last_period
     72        );
     73        _Timestamp_To_timespec(
     74          &executed, &status->executed_since_last_period
     75        );
    9076      }
    9177
  • cpukit/rtems/src/ratemonperiod.c

    r80fca28 re6b31b27  
    3131)
    3232{
    33   #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    34     Timestamp_Control        uptime;
    35   #endif
    36     Thread_Control          *owning_thread = the_period->owner;
    37     Thread_CPU_usage_t       used;
     33  Timestamp_Control        uptime;
     34  Thread_Control          *owning_thread = the_period->owner;
     35  Thread_CPU_usage_t       used;
    3836
    3937  /*
    4038   *  Determine elapsed wall time since period initiated.
    4139   */
    42   #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    43     _TOD_Get_uptime( &uptime );
     40  _TOD_Get_uptime( &uptime );
     41  _Timestamp_Subtract(
     42    &the_period->time_period_initiated, &uptime, wall_since_last_period
     43  );
     44
     45  /*
     46   *  Determine cpu usage since period initiated.
     47   */
     48  used = owning_thread->cpu_time_used;
     49
     50  if (owning_thread == _Thread_Executing) {
     51
     52    Thread_CPU_usage_t ran;
     53
     54    /* How much time time since last context switch */
    4455    _Timestamp_Subtract(
    45       &the_period->time_period_initiated, &uptime, wall_since_last_period
     56      &_Thread_Time_of_last_context_switch, &uptime, &ran
    4657    );
    47   #else
    48     *wall_since_last_period =
    49       _Watchdog_Ticks_since_boot - the_period->time_period_initiated;
    50   #endif
    51 
    52   /*
    53    *  Determine cpu usage since period initiated.
    54    */
    55   used = owning_thread->cpu_time_used;
    56 
    57   #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    58     if (owning_thread == _Thread_Executing) {
    59 
    60       Thread_CPU_usage_t ran;
    61 
    62       /* How much time time since last context switch */
    63       _Timestamp_Subtract(
    64         &_Thread_Time_of_last_context_switch, &uptime, &ran
    65       );
    66 
    67       /* cpu usage += ran */
    68       _Timestamp_Add_to( &used, &ran );
    69 
    70       /*
    71        *  The cpu usage info was reset while executing.  Can't
    72        *  determine a status.
    73        */
    74       if (_Timestamp_Less_than(&used, &the_period->cpu_usage_period_initiated))
    75         return false;
    76 
    77        /* used = current cpu usage - cpu usage at start of period */
    78       _Timestamp_Subtract(
    79          &the_period->cpu_usage_period_initiated,
    80          &used,
    81          cpu_since_last_period
    82       );
    83     }
    84   #else
    85       /*
    86        *  The cpu usage info was reset while executing.  Can't
    87        *  determine a status.
    88        */
    89       if (used < the_period->cpu_usage_period_initiated)
    90         return false;
    91 
    92       *cpu_since_last_period = used - the_period->cpu_usage_period_initiated;
    93   #endif
     58
     59    /* cpu usage += ran */
     60    _Timestamp_Add_to( &used, &ran );
     61
     62    /*
     63     *  The cpu usage info was reset while executing.  Can't
     64     *  determine a status.
     65     */
     66    if (_Timestamp_Less_than(&used, &the_period->cpu_usage_period_initiated))
     67      return false;
     68
     69     /* used = current cpu usage - cpu usage at start of period */
     70    _Timestamp_Subtract(
     71       &the_period->cpu_usage_period_initiated,
     72       &used,
     73       cpu_since_last_period
     74    );
     75  }
     76
    9477  return true;
    9578}
  • cpukit/rtems/src/ratemonreportstatistics.c

    r80fca28 re6b31b27  
    2424#include <inttypes.h>
    2525
    26 #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    27   /* We print to 1/10's of milliseconds */
    28   #define NANOSECONDS_DIVIDER 1000
    29   #define PERCENT_FMT     "%04" PRId32
    30   #define NANOSECONDS_FMT "%06" PRId32
    31 #endif
     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
    3230
    3331void rtems_rate_monotonic_report_statistics_with_plugin(
     
    4644
    4745  (*print)( context, "Period information by period\n" );
    48   #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    49     (*print)( context, "--- CPU times are in seconds ---\n" );
    50     (*print)( context, "--- Wall times are in seconds ---\n" );
    51   #endif
     46  (*print)( context, "--- CPU times are in seconds ---\n" );
     47  (*print)( context, "--- Wall times are in seconds ---\n" );
    5248/*
    5349Layout by columns -- in memory of Hollerith :)
     
    6359\n");
    6460*/
    65   (*print)( context, "   ID     OWNER COUNT MISSED     "
    66        #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    67           "     "
    68        #endif
    69           "CPU TIME     "
    70        #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    71           "          "
    72        #endif
    73           "   WALL TIME\n"
    74   );
    75   (*print)( context, "                               "
    76        #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    77           "     "
    78        #endif
    79           "MIN/MAX/AVG    "
    80        #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    81           "          "
    82        #endif
    83           "  MIN/MAX/AVG\n"
     61  (*print)( context,
     62      "   ID     OWNER COUNT MISSED     "
     63      "     CPU TIME                  WALL TIME\n"
     64      "                               "
     65      "     MIN/MAX/AVG                MIN/MAX/AVG\n"
    8466  );
    8567
     
    127109     */
    128110    {
    129     #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    130111      struct timespec  cpu_average;
    131112      struct timespec *min_cpu = &the_stats.min_cpu_time;
     
    145126          _Timespec_Get_nanoseconds( &cpu_average ) / NANOSECONDS_DIVIDER
    146127       );
    147     #else
    148       uint32_t ival_cpu, fval_cpu;
    149 
    150       ival_cpu = the_stats.total_cpu_time * 100 / the_stats.count;
    151       fval_cpu = ival_cpu % 100;
    152       ival_cpu /= 100;
    153 
    154       (*print)( context,
    155         "%3" PRId32 "/%4" PRId32 "/%3" PRId32 ".%02" PRId32 " ",
    156         the_stats.min_cpu_time, the_stats.max_cpu_time, ival_cpu, fval_cpu
    157       );
    158     #endif
    159128    }
    160129
     
    163132     */
    164133    {
    165     #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    166134      struct timespec  wall_average;
    167135      struct timespec *min_wall = &the_stats.min_wall_time;
     
    181149          _Timespec_Get_nanoseconds( &wall_average ) / NANOSECONDS_DIVIDER
    182150      );
    183     #else
    184       uint32_t  ival_wall, fval_wall;
    185 
    186       ival_wall = the_stats.total_wall_time * 100 / the_stats.count;
    187       fval_wall = ival_wall % 100;
    188       ival_wall /= 100;
    189       (*print)( context,
    190         "%3" PRId32 "/%4" PRId32 "/%3" PRId32 ".%02" PRId32 "\n",
    191         the_stats.min_wall_time, the_stats.max_wall_time, ival_wall, fval_wall
    192       );
    193     #endif
    194151    }
    195152  }
  • cpukit/score/include/rtems/score/thread.h

    r80fca28 re6b31b27  
    8484 *  resolution.
    8585 */
    86 #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    87   #include <rtems/score/timestamp.h>
    88 
    89   typedef Timestamp_Control Thread_CPU_usage_t;
    90 #else
    91   typedef uint32_t Thread_CPU_usage_t;
    92 #endif
     86#include <rtems/score/timestamp.h>
     87
     88typedef Timestamp_Control Thread_CPU_usage_t;
    9389
    9490/**
  • cpukit/score/src/schedulerdefaulttick.c

    r80fca28 re6b31b27  
    3131{
    3232  (void) scheduler;
    33 
    34   #ifdef __RTEMS_USE_TICKS_FOR_STATISTICS__
    35     /*
    36      *  Increment the number of ticks this thread has been executing
    37      */
    38     executing->cpu_time_used++;
    39   #endif
    4033
    4134  /*
  • cpukit/score/src/threaddispatch.c

    r80fca28 re6b31b27  
    100100#endif
    101101
    102     #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    103       _Thread_Update_cpu_time_used(
    104         executing,
    105         &cpu_self->time_of_last_context_switch
    106       );
    107     #else
    108       {
    109         _TOD_Get_uptime( &cpu_self->time_of_last_context_switch );
    110         heir->cpu_time_used++;
    111       }
    112     #endif
     102    _Thread_Update_cpu_time_used(
     103      executing,
     104      &cpu_self->time_of_last_context_switch
     105    );
    113106
    114107#if !defined(__DYNAMIC_REENT__)
  • cpukit/score/src/threadinitialize.c

    r80fca28 re6b31b27  
    218218   *  Initialize the CPU usage statistics
    219219   */
    220   #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    221     _Timestamp_Set_to_zero( &the_thread->cpu_time_used );
    222   #else
    223     the_thread->cpu_time_used = 0;
    224   #endif
     220  _Timestamp_Set_to_zero( &the_thread->cpu_time_used );
    225221
    226222  /*
  • testsuites/sptests/sp69/init.c

    r80fca28 re6b31b27  
    5656  rtems_test_assert( period_status.owner == rtems_task_self() );
    5757  rtems_test_assert( period_status.state == RATE_MONOTONIC_INACTIVE );
    58   #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    59     rtems_test_assert( period_status.since_last_period.tv_sec == 0 );
    60     rtems_test_assert( period_status.since_last_period.tv_nsec == 0 );
    61     rtems_test_assert( period_status.executed_since_last_period.tv_sec == 0 );
    62     rtems_test_assert( period_status.executed_since_last_period.tv_nsec == 0 );
    63   #else
    64     rtems_test_assert( period_status.since_last_period == 0 );
    65     rtems_test_assert( period_status.executed_since_last_period == 0 );
    66   #endif
     58  rtems_test_assert( period_status.since_last_period.tv_sec == 0 );
     59  rtems_test_assert( period_status.since_last_period.tv_nsec == 0 );
     60  rtems_test_assert( period_status.executed_since_last_period.tv_sec == 0 );
     61  rtems_test_assert( period_status.executed_since_last_period.tv_nsec == 0 );
    6762
    6863  /*
     
    114109
    115110  /* Check status values. */
    116   #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    117111  /* Note: POSIX mandates struct timespec->tv_nsec to be a "long" */
    118     printf(
    119       "wall time should be ~600000000 is %ld\n",
    120       period_status.since_last_period.tv_nsec
    121     );
    122     printf(
    123       "cpu time should be ~100000000 is %ld\n",
    124       period_status.executed_since_last_period.tv_nsec
    125     );
    126     rtems_test_assert( period_status.since_last_period.tv_sec == 0 );
    127     rtems_test_assert( period_status.since_last_period.tv_nsec >= 600000000 );
    128     rtems_test_assert( period_status.since_last_period.tv_nsec <= 610000000 );
    129     rtems_test_assert( period_status.executed_since_last_period.tv_sec == 0 );
    130     rtems_test_assert(
    131       period_status.executed_since_last_period.tv_nsec >= 100000000
    132     );
    133     rtems_test_assert(
    134       period_status.executed_since_last_period.tv_nsec <= 110000000
    135     );
    136   #else
    137     printf(
    138       "wall time should be ~60 is %" PRId32 "\n",
    139       (int) period_status.since_last_period
    140     );
    141     printf(
    142       "cpu time should be ~10 is %" PRId32 "\n",
    143       (int) period_status.executed_since_last_period
    144     );
    145     rtems_test_assert( period_status.since_last_period >= 60 );
    146     rtems_test_assert( period_status.since_last_period <= 61 );
    147     rtems_test_assert( period_status.executed_since_last_period >= 10 );
    148     rtems_test_assert( period_status.executed_since_last_period <= 12 );
    149   #endif
     112  printf(
     113    "wall time should be ~600000000 is %ld\n",
     114    period_status.since_last_period.tv_nsec
     115  );
     116  printf(
     117    "cpu time should be ~100000000 is %ld\n",
     118    period_status.executed_since_last_period.tv_nsec
     119  );
     120  rtems_test_assert( period_status.since_last_period.tv_sec == 0 );
     121  rtems_test_assert( period_status.since_last_period.tv_nsec >= 600000000 );
     122  rtems_test_assert( period_status.since_last_period.tv_nsec <= 610000000 );
     123  rtems_test_assert( period_status.executed_since_last_period.tv_sec == 0 );
     124  rtems_test_assert(
     125    period_status.executed_since_last_period.tv_nsec >= 100000000
     126  );
     127  rtems_test_assert(
     128    period_status.executed_since_last_period.tv_nsec <= 110000000
     129  );
    150130
    151131  /* ensure the missed periods are properly accounted for */
Note: See TracChangeset for help on using the changeset viewer.