summaryrefslogtreecommitdiffstats
path: root/cpukit/score/include/rtems/score/todimpl.h
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2013-07-31 13:30:42 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2013-08-01 16:45:46 +0200
commit9bf74673f928788b0ea4addabf045b94844d40ff (patch)
tree495ca384343769feefd96f88061ccc5ed5f192bb /cpukit/score/include/rtems/score/todimpl.h
parentscore: Move nanoseconds since last tick support (diff)
downloadrtems-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 'cpukit/score/include/rtems/score/todimpl.h')
-rw-r--r--cpukit/score/include/rtems/score/todimpl.h35
1 files changed, 25 insertions, 10 deletions
diff --git a/cpukit/score/include/rtems/score/todimpl.h b/cpukit/score/include/rtems/score/todimpl.h
index a7c3e5d737..097965cbc7 100644
--- a/cpukit/score/include/rtems/score/todimpl.h
+++ b/cpukit/score/include/rtems/score/todimpl.h
@@ -19,6 +19,7 @@
#define _RTEMS_SCORE_TODIMPL_H
#include <rtems/score/tod.h>
+#include <rtems/score/isrlock.h>
#include <rtems/score/timestamp.h>
#include <sys/time.h>
@@ -130,16 +131,25 @@ extern "C" {
*/
typedef struct {
/**
- * @brief Current time of day value.
+ * @brief Current time of day value.
+ *
+ * This field is protected by the lock.
*/
Timestamp_Control now;
/**
- * @brief System uptime.
+ * @brief System uptime.
+ *
+ * This field is protected by the lock.
*/
Timestamp_Control uptime;
/**
+ * @brief Lock to protect the now and uptime fields.
+ */
+ ISR_lock_Control lock;
+
+ /**
* @brief Time of day seconds trigger.
*
* This value specifies the nanoseconds since the last time of day second.
@@ -166,14 +176,11 @@ typedef struct {
SCORE_EXTERN TOD_Control _TOD;
-/**
- * @brief Number of seconds Since RTEMS epoch.
- *
- * The following contains the number of seconds from 00:00:00
- * January 1, TOD_BASE_YEAR until the current time of day.
- */
-#define _TOD_Seconds_since_epoch() \
- _Timestamp_Get_seconds(&_TOD.now)
+#define _TOD_Acquire( _tod, _isr_cookie ) \
+ _ISR_lock_ISR_disable_and_acquire( &( _tod )->lock, _isr_cookie )
+
+#define _TOD_Release( _tod, _isr_cookie ) \
+ _ISR_lock_Release_and_ISR_enable( &( _tod )->lock, _isr_cookie )
/**
* @brief Initializes the time of day handler.
@@ -264,6 +271,14 @@ void _TOD_Get_uptime_as_timespec(
);
/**
+ * @brief Number of seconds Since RTEMS epoch.
+ *
+ * The following contains the number of seconds from 00:00:00
+ * January 1, TOD_BASE_YEAR until the current time of day.
+ */
+uint32_t _TOD_Seconds_since_epoch( void );
+
+/**
* @brief Increments time of day at each clock tick.
*
* This routine increments the ticks field of the current time of