Changeset c34bb0d in rtems


Ignore:
Timestamp:
Jun 13, 2012, 9:39:43 AM (8 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
c39148d, c4faa47
Parents:
3246b0f8
git-author:
Sebastian Huber <sebastian.huber@…> (06/13/12 09:39:43)
git-committer:
Sebastian Huber <sebastian.huber@…> (06/14/12 12:20:30)
Message:

score: Fix performance issue for 64-bit timestamps

The 64-bit timestamps were introduced to simplify the timestamp
calculations. This works well since nearly all operations are
additions. The previous _TOD_Tickle_ticks() implementation had a
serious performance regression in case of 64-bit timestamps due to the
usage of two 64-bit divisions which are quite expensive on some
architectures.

A new field seconds_trigger in TOD_Control is introduced to trigger the
_Watchdog_Tickle_seconds() in _TOD_Tickle_ticks(). This avoids the
64-bit divisions completely and only 32-bit additions are used.

Location:
cpukit/score
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • cpukit/score/include/rtems/score/timestamp.h

    r3246b0f8 rc34bb0d  
    195195
    196196/**
    197  *  @brief Add to a Timestamp (At Clock Tick)
    198  *
    199  *  This routine adds two timestamps.  The second argument is added
    200  *  to the first.
    201  *
    202  *  @node This routine places a special requirement on the addition
    203  *        operation.  It must return the number of units that the
    204  *        seconds field changed as the result of the addition.  Since this
    205  *        operation is ONLY used as part of processing a clock tick,
    206  *        it is generally safe to assume that only one second changed.
    207  *
    208  *  @param[in] _time points to the base time to be added to
    209  *  @param[in] _add points to the timestamp to add to the first argument
    210  *
    211  *  @return This method returns the number of seconds @a time increased by.
    212  */
    213 #if CPU_TIMESTAMP_USE_STRUCT_TIMESPEC == TRUE
    214   #define _Timestamp_Add_to_at_tick( _time, _add ) \
    215           _Timespec_Add_to( _time, _add )
    216 #else
    217   #define _Timestamp_Add_to_at_tick( _time, _add ) \
    218           _Timestamp64_Add_to_at_tick( _time, _add )
    219 #endif
    220 
    221 /**
    222197 *  @brief Convert Timestamp to Number of Ticks
    223198 *
  • cpukit/score/include/rtems/score/timestamp64.h

    r3246b0f8 rc34bb0d  
    208208  );
    209209#endif
    210 
    211 /**
    212  *  @brief Add to a Timestamp (At Clock Tick)
    213  *
    214  *  This routine adds two timestamps.  The second argument is added
    215  *  to the first.
    216  *
    217  *  @node This routine places a special requirement on the addition
    218  *        operation.  It must return the number of units that the
    219  *        seconds field changed as the result of the addition.  Since this
    220  *        operation is ONLY used as part of processing a clock tick,
    221  *        it is generally safe to assume that only one second changed.
    222  *
    223  *  @param[in] _time points to the base time to be added to
    224  *  @param[in] _add points to the timestamp to add to the first argument
    225  *
    226  *  @return This method returns the number of seconds @a time increased by.
    227  */
    228 static inline uint32_t _Timestamp64_Add_to_at_tick(
    229   Timestamp64_Control *_time,
    230   const Timestamp64_Control *_add
    231 )
    232 {
    233   Timestamp64_Control _start = *_time / 1000000000L;
    234   *_time += *_add;
    235   if ( ((*_time) / 1000000000L) != _start ) {
    236     return 1;
    237   }
    238   return 0;
    239 }
    240210
    241211/**
  • cpukit/score/include/rtems/score/tod.h

    r3246b0f8 rc34bb0d  
    136136   */
    137137  Timestamp_Control uptime;
     138
     139  /**
     140   * @brief Time of day seconds trigger.
     141   *
     142   * This value specifies the nanoseconds since the last time of day second.
     143   * It is updated and evaluated in _TOD_Tickle_ticks().  It is set in
     144   * _TOD_Set_with_timestamp().
     145   */
     146  uint32_t seconds_trigger;
    138147
    139148  /**
  • cpukit/score/src/coretodset.c

    r3246b0f8 rc34bb0d  
    2626)
    2727{
     28  uint32_t nanoseconds = _Timestamp_Get_nanoseconds( tod );
    2829  Watchdog_Interval seconds_next = _Timestamp_Get_seconds( tod );
    2930  Watchdog_Interval seconds_now;
     
    4041
    4142  _TOD.now = *tod;
     43  _TOD.seconds_trigger = nanoseconds;
    4244  _TOD.is_set = true;
    4345
  • cpukit/score/src/coretodtickle.c

    r3246b0f8 rc34bb0d  
    3636{
    3737  Timestamp_Control tick;
    38   uint32_t          seconds;
     38  uint32_t          nanoseconds_per_tick;
     39
     40  nanoseconds_per_tick = rtems_configuration_get_nanoseconds_per_tick();
    3941
    4042  /* Convert the tick quantum to a timestamp */
    41   _Timestamp_Set( &tick, 0, rtems_configuration_get_nanoseconds_per_tick() );
     43  _Timestamp_Set( &tick, 0, nanoseconds_per_tick );
    4244
    4345  /* Update the counter of ticks since boot */
    4446  _Watchdog_Ticks_since_boot += 1;
    4547
    46   /* Update the timespec format uptime */
     48  /* Update the uptime */
    4749  _Timestamp_Add_to( &_TOD.uptime, &tick );
    4850  /* we do not care how much the uptime changed */
    4951
    50   /* Update the timespec format TOD */
    51   seconds = _Timestamp_Add_to_at_tick( &_TOD.now, &tick );
    52   while ( seconds ) {
     52  /* Update the current TOD */
     53  _Timestamp_Add_to( &_TOD.now, &tick );
     54
     55  _TOD.seconds_trigger += nanoseconds_per_tick;
     56  if ( _TOD.seconds_trigger >= 1000000000UL ) {
     57    _TOD.seconds_trigger -= 1000000000UL;
    5358    _Watchdog_Tickle_seconds();
    54     seconds--;
    5559  }
    5660}
Note: See TracChangeset for help on using the changeset viewer.