Changeset ec2078d in rtems


Ignore:
Timestamp:
May 21, 2007, 7:28:55 PM (13 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
a205b96b
Parents:
4741b0b2
Message:

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

  • rtems/src/ratemonperiod.c: Fix math ordering bug which resulted in a negative value in some circumstances. Also cleaned up to share uptime declaration.
Location:
cpukit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ChangeLog

    r4741b0b2 rec2078d  
     12007-05-21      Joel Sherrill <joel.sherrill@oarcorp.com>
     2
     3        * rtems/src/ratemonperiod.c: Fix math ordering bug which resulted in a
     4        negative value in some circumstances. Also cleaned up to share uptime
     5        declaration.
     6
    172007-05-17      Joel Sherrill <joel.sherrill@oarcorp.com>
    28
  • cpukit/rtems/src/ratemonperiod.c

    r4741b0b2 rec2078d  
    7777  #ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
    7878    {
    79       struct timespec ran;
     79      struct timespec ran, used;
    8080       
     81      /* Grab CPU usage when the thread got switched in */
     82      used = _Thread_Executing->cpu_time_used;
     83
     84      /* How much time time since last context switch */
     85      _Timespec_Subtract(&_Thread_Time_of_last_context_switch, &uptime, &ran);
     86
     87      /* executed += ran */
     88      _Timespec_Add_to( &used, &ran );
     89
    8190       /* executed = current cpu usage - value at start of period */
    8291      _Timespec_Subtract(
    8392         &the_period->owner_executed_at_period,
    84          &_Thread_Executing->cpu_time_used,
     93         &used,
    8594         &executed
    8695      );
    87 
    88       /* How much time time since last context switch */
    89       _Timespec_Subtract(&_Thread_Time_of_last_context_switch, &uptime, &ran);
    90 
    91       /* executed += ran */
    92       _Timespec_Add_to( &executed, &ran );
    9396    }
    9497  #else
     
    103106  stats = &the_period->Statistics;
    104107  stats->count++;
     108
    105109
    106110  if ( the_period->state == RATE_MONOTONIC_EXPIRED )
     
    215219      _ISR_Disable( level );
    216220      switch ( the_period->state ) {
    217         case RATE_MONOTONIC_INACTIVE:
     221        case RATE_MONOTONIC_INACTIVE: {
     222          #if defined(RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS) || \
     223              defined(RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS)
     224            struct timespec uptime;
     225          #endif
     226
    218227          /*
    219228           *  No need to update statistics -- there are not a period active
     
    222231          _ISR_Enable( level );
    223232
     233
     234          #if defined(RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS) || \
     235              defined(RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS)
     236            _TOD_Get_uptime( &uptime );
     237          #endif
     238             
    224239          #ifdef RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS
    225240            /*
     
    227242             * we do it here.
    228243             */
    229             _TOD_Get_uptime( &the_period->time_at_period );
     244            the_period->time_at_period = uptime;
    230245          #else
    231246            the_period->time_at_period = _Watchdog_Ticks_since_boot;
     
    234249          #ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
    235250            {
    236               struct timespec ran, uptime;
    237 
    238               _TOD_Get_uptime( &uptime );
    239              
     251              struct timespec ran;
     252
    240253              the_period->owner_executed_at_period =
    241254                _Thread_Executing->cpu_time_used;
     
    269282          _Thread_Enable_dispatch();
    270283          return RTEMS_SUCCESSFUL;
    271 
     284        }
    272285        case RATE_MONOTONIC_ACTIVE:
    273286
Note: See TracChangeset for help on using the changeset viewer.