summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/coretodtickle.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2012-06-13 11:39:43 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2012-06-14 14:20:30 +0200
commitc34bb0dcfa8ba1294cd5182349e1ddbe34f81bf4 (patch)
tree249469ef52fd9829a59ca914322805c351267da1 /cpukit/score/src/coretodtickle.c
parentscore: New structure TOD_Control (diff)
downloadrtems-c34bb0dcfa8ba1294cd5182349e1ddbe34f81bf4.tar.bz2
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.
Diffstat (limited to 'cpukit/score/src/coretodtickle.c')
-rw-r--r--cpukit/score/src/coretodtickle.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/cpukit/score/src/coretodtickle.c b/cpukit/score/src/coretodtickle.c
index fbf67fda79..d0412f85d4 100644
--- a/cpukit/score/src/coretodtickle.c
+++ b/cpukit/score/src/coretodtickle.c
@@ -35,23 +35,27 @@
void _TOD_Tickle_ticks( void )
{
Timestamp_Control tick;
- uint32_t seconds;
+ uint32_t nanoseconds_per_tick;
+
+ nanoseconds_per_tick = rtems_configuration_get_nanoseconds_per_tick();
/* Convert the tick quantum to a timestamp */
- _Timestamp_Set( &tick, 0, rtems_configuration_get_nanoseconds_per_tick() );
+ _Timestamp_Set( &tick, 0, nanoseconds_per_tick );
/* Update the counter of ticks since boot */
_Watchdog_Ticks_since_boot += 1;
- /* Update the timespec format uptime */
+ /* Update the uptime */
_Timestamp_Add_to( &_TOD.uptime, &tick );
/* we do not care how much the uptime changed */
- /* Update the timespec format TOD */
- seconds = _Timestamp_Add_to_at_tick( &_TOD.now, &tick );
- while ( seconds ) {
+ /* Update the current TOD */
+ _Timestamp_Add_to( &_TOD.now, &tick );
+
+ _TOD.seconds_trigger += nanoseconds_per_tick;
+ if ( _TOD.seconds_trigger >= 1000000000UL ) {
+ _TOD.seconds_trigger -= 1000000000UL;
_Watchdog_Tickle_seconds();
- seconds--;
}
}