From 9bf74673f928788b0ea4addabf045b94844d40ff Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 31 Jul 2013 13:30:42 +0200 Subject: score: Use an ISR lock for TOD Two issues are addressed. 1. On single processor configurations the set/get of the now/uptime timestamps is now consistently protected by ISR disable/enable sequences. Previously nested interrupts could observe partially written values since 64-bit writes are not atomic on 32-bit architectures in general. This could lead to non-monotonic uptime timestamps. 2. The TOD now/uptime maintanence is now independent of the giant lock. This is the first step to remove the giant lock in _Thread_Dispatch(). --- cpukit/score/src/coretodtickle.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'cpukit/score/src/coretodtickle.c') diff --git a/cpukit/score/src/coretodtickle.c b/cpukit/score/src/coretodtickle.c index 4586e8496f..c9f9597b1d 100644 --- a/cpukit/score/src/coretodtickle.c +++ b/cpukit/score/src/coretodtickle.c @@ -24,8 +24,10 @@ void _TOD_Tickle_ticks( void ) { - Timestamp_Control tick; - uint32_t nanoseconds_per_tick; + TOD_Control *tod = &_TOD; + ISR_Level level; + Timestamp_Control tick; + uint32_t nanoseconds_per_tick; nanoseconds_per_tick = rtems_configuration_get_nanoseconds_per_tick(); @@ -35,12 +37,15 @@ void _TOD_Tickle_ticks( void ) /* Update the counter of ticks since boot */ _Watchdog_Ticks_since_boot += 1; + _TOD_Acquire( tod, level ); + /* Update the uptime */ - _Timestamp_Add_to( &_TOD.uptime, &tick ); - /* we do not care how much the uptime changed */ + _Timestamp_Add_to( &tod->uptime, &tick ); /* Update the current TOD */ - _Timestamp_Add_to( &_TOD.now, &tick ); + _Timestamp_Add_to( &tod->now, &tick ); + + _TOD_Release( tod, level ); _TOD.seconds_trigger += nanoseconds_per_tick; if ( _TOD.seconds_trigger >= 1000000000UL ) { -- cgit v1.2.3