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/coretodsecondssinceepoch.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 'cpukit/score/src/coretodsecondssinceepoch.c')
-rw-r--r-- | cpukit/score/src/coretodsecondssinceepoch.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/cpukit/score/src/coretodsecondssinceepoch.c b/cpukit/score/src/coretodsecondssinceepoch.c new file mode 100644 index 0000000000..91445c0c80 --- /dev/null +++ b/cpukit/score/src/coretodsecondssinceepoch.c @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2013 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * <rtems@embedded-brains.de> + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + */ + +#if HAVE_CONFIG_H + #include "config.h" +#endif + +#include <rtems/score/todimpl.h> + +uint32_t _TOD_Seconds_since_epoch( void ) +{ + TOD_Control *tod = &_TOD; + ISR_Level level; + Timestamp_Control now; + + _TOD_Acquire( tod, level ); + now = tod->now; + _TOD_Release( tod, level ); + + return _Timestamp_Get_seconds( &now ); +} |