diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-04-27 22:07:56 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-05-02 07:46:16 +0200 |
commit | 1ef8e4a8e93a848e2a68f37e029039300f1c936b (patch) | |
tree | 1a592f827f25a7803f4c70520efd8ce514a523e6 /cpukit/score/include/rtems/score/todimpl.h | |
parent | score: Streamline set time of day functions (diff) | |
download | rtems-1ef8e4a8e93a848e2a68f37e029039300f1c936b.tar.bz2 |
score: Avoid Giant lock for set time of day
Update #2555.
Update #2630.
Diffstat (limited to 'cpukit/score/include/rtems/score/todimpl.h')
-rw-r--r-- | cpukit/score/include/rtems/score/todimpl.h | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/cpukit/score/include/rtems/score/todimpl.h b/cpukit/score/include/rtems/score/todimpl.h index 2b07823e14..f53e36577d 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/apimutex.h> #include <rtems/score/timestamp.h> #include <rtems/score/timecounterimpl.h> #include <rtems/score/watchdog.h> @@ -142,14 +143,36 @@ typedef struct { extern TOD_Control _TOD; +static inline void _TOD_Lock( void ) +{ + /* FIXME: https://devel.rtems.org/ticket/2630 */ + _API_Mutex_Lock( _Once_Mutex ); +} + +static inline void _TOD_Unlock( void ) +{ + _API_Mutex_Unlock( _Once_Mutex ); +} + +static inline void _TOD_Acquire( ISR_lock_Context *lock_context ) +{ + _Timecounter_Acquire( lock_context ); +} + /** * @brief Sets the time of day. * + * The caller must be the owner of the TOD lock. + * * @param tod_as_timestamp The new time of day in timestamp format representing * the time since UNIX Epoch. + * @param lock_context The ISR lock context used for the corresponding + * _TOD_Acquire(). The caller must be the owner of the TOD lock. This + * function will release the TOD lock. */ void _TOD_Set( - const Timestamp_Control *tod_as_timestamp + const Timestamp_Control *tod_as_timestamp, + ISR_lock_Context *lock_context ); /** @@ -164,13 +187,18 @@ static inline void _TOD_Set_with_timespec( ) { Timestamp_Control tod_as_timestamp; + ISR_lock_Context lock_context; _Timestamp_Set( &tod_as_timestamp, tod_as_timespec->tv_sec, tod_as_timespec->tv_nsec ); - _TOD_Set( &tod_as_timestamp ); + + _TOD_Lock(); + _TOD_Acquire( &lock_context ); + _TOD_Set( &tod_as_timestamp, &lock_context ); + _TOD_Unlock(); } /** @@ -296,7 +324,7 @@ RTEMS_INLINE_ROUTINE void _TOD_Get_timeval( * @param[in] delta is the amount to adjust */ void _TOD_Adjust( - const Timestamp_Control timestamp + const Timestamp_Control *delta ); /** |