diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2013-07-31 13:30:42 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2013-08-01 16:45:46 +0200 |
commit | 9bf74673f928788b0ea4addabf045b94844d40ff (patch) | |
tree | 495ca384343769feefd96f88061ccc5ed5f192bb /cpukit/score/src/coretodset.c | |
parent | score: Move nanoseconds since last tick support (diff) | |
download | rtems-9bf74673f928788b0ea4addabf045b94844d40ff.tar.bz2 |
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().
Diffstat (limited to '')
-rw-r--r-- | cpukit/score/src/coretodset.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/cpukit/score/src/coretodset.c b/cpukit/score/src/coretodset.c index ff76581bbd..c265606137 100644 --- a/cpukit/score/src/coretodset.c +++ b/cpukit/score/src/coretodset.c @@ -23,12 +23,14 @@ #include <rtems/score/watchdogimpl.h> void _TOD_Set_with_timestamp( - const Timestamp_Control *tod + const Timestamp_Control *tod_as_timestamp ) { - uint32_t nanoseconds = _Timestamp_Get_nanoseconds( tod ); - Watchdog_Interval seconds_next = _Timestamp_Get_seconds( tod ); + TOD_Control *tod = &_TOD; + uint32_t nanoseconds = _Timestamp_Get_nanoseconds( tod_as_timestamp ); + Watchdog_Interval seconds_next = _Timestamp_Get_seconds( tod_as_timestamp ); Watchdog_Interval seconds_now; + ISR_Level level; _Thread_Disable_dispatch(); @@ -39,9 +41,12 @@ void _TOD_Set_with_timestamp( else _Watchdog_Adjust_seconds( WATCHDOG_FORWARD, seconds_next - seconds_now ); - _TOD.now = *tod; - _TOD.seconds_trigger = nanoseconds; - _TOD.is_set = true; + _TOD_Acquire( tod, level ); + tod->now = *tod_as_timestamp; + _TOD_Release( tod, level ); + + tod->seconds_trigger = nanoseconds; + tod->is_set = true; _Thread_Enable_dispatch(); } |