#3902 new defect

rate monotonic statistics not resetting correctly

Reported by: Martin Erik Werner Owned by:
Priority: normal Milestone:
Component: rtems Version: 4.11
Severity: normal Keywords:
Cc: Blocked By:


When resetting the rate monotonic statistics, the max wall time and total wall time values are not being reset.

This issue affects RTEMS 4.11 but does not affect RTEMS 5.

In the 4.11 implementation for the reset:

// cpukit/rtems/include/rtems/rtems/ratemonimpl.h
#define _Rate_monotonic_Reset_statistics( _the_period ) \
  do { \
    memset( \
      &(_the_period)->Statistics, \
      0, \
      sizeof( rtems_rate_monotonic_period_statistics ) \
    ); \
    _Rate_monotonic_Reset_cpu_use_statistics( _the_period ); \
    _Rate_monotonic_Reset_wall_time_statistics( _the_period ); \
  } while (0)

The zeroing size is calculated based on the rtems_rate_monotonic_period_statistics which is the public API struct and not the same type as the internal Statistics member that it is trying to reset, which is instead of type Rate_monotonic_Statistics.

These structures have different sizes and the rtems_rate_monotonic_period_statistics struct is 48 bytes smaller than the Rate_monotonic_Statistics struct. This means that the memset zeroes too little.

The subsequent _Rate_monotonic_Reset* calls takes care of resetting some additional members but the two at the end (max wall and total wall) are left without being reset.

a fix would be:

  • cpukit/rtems/include/rtems/rtems/ratemonimpl.h

    diff --git a/cpukit/rtems/include/rtems/rtems/ratemonimpl.h b/cpukit/rtems/include/rtems/rtems/ratemonimpl.h
    index b3aa1cf303..a57dd1056a 100644
    a b void _Rate_monotonic_Initiate_statistics( 
    236236    memset( \
    237237      &(_the_period)->Statistics, \
    238238      0, \
    239       sizeof( rtems_rate_monotonic_period_statistics ) \
     239      sizeof( (_the_period)->Statistics ) \
    240240    ); \
    241241    _Rate_monotonic_Reset_cpu_use_statistics( _the_period ); \
    242242    _Rate_monotonic_Reset_wall_time_statistics( _the_period ); \

In RTEMS 5, the size for the memset is calculated correctly and the statistics are reset correctly. (The size has also swapped, such that the public API struct is now larger than the internal struct.)

Change History (0)

Note: See TracTickets for help on using tickets.