summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/score/src')
-rw-r--r--cpukit/score/src/coretodset.c6
-rw-r--r--cpukit/score/src/watchdogadjust.c67
2 files changed, 35 insertions, 38 deletions
diff --git a/cpukit/score/src/coretodset.c b/cpukit/score/src/coretodset.c
index 6006e66c2f..8c4ef8b135 100644
--- a/cpukit/score/src/coretodset.c
+++ b/cpukit/score/src/coretodset.c
@@ -31,15 +31,17 @@ void _TOD_Set_with_timestamp(
Watchdog_Interval seconds_next = _Timestamp_Get_seconds( tod_as_timestamp );
Watchdog_Interval seconds_now;
ISR_lock_Context lock_context;
+ Chain_Control *header;
_Thread_Disable_dispatch();
seconds_now = _TOD_Seconds_since_epoch();
+ header = &_Watchdog_Seconds_chain;
if ( seconds_next < seconds_now )
- _Watchdog_Adjust_seconds( WATCHDOG_BACKWARD, seconds_now - seconds_next );
+ _Watchdog_Adjust_backward( header, seconds_now - seconds_next );
else
- _Watchdog_Adjust_seconds( WATCHDOG_FORWARD, seconds_next - seconds_now );
+ _Watchdog_Adjust_forward( header, seconds_next - seconds_now );
_TOD_Acquire( tod, &lock_context );
tod->now = *tod_as_timestamp;
diff --git a/cpukit/score/src/watchdogadjust.c b/cpukit/score/src/watchdogadjust.c
index bbfda4d0cf..5d841049dc 100644
--- a/cpukit/score/src/watchdogadjust.c
+++ b/cpukit/score/src/watchdogadjust.c
@@ -18,57 +18,52 @@
#include "config.h"
#endif
-#include <rtems/system.h>
-#include <rtems/score/isr.h>
#include <rtems/score/watchdogimpl.h>
+#include <rtems/score/chainimpl.h>
+#include <rtems/score/isrlevel.h>
-void _Watchdog_Adjust(
- Chain_Control *header,
- Watchdog_Adjust_directions direction,
- Watchdog_Interval units
+void _Watchdog_Adjust_backward(
+ Chain_Control *header,
+ Watchdog_Interval units
)
{
ISR_Level level;
_ISR_Disable( level );
- /*
- * NOTE: It is safe NOT to make 'header' a pointer
- * to volatile data (contrast this with watchdoginsert.c)
- * because we call _Watchdog_Tickle() below and
- * hence the compiler must not assume *header to remain
- * unmodified across that call.
- *
- * Till Straumann, 7/2003
- */
if ( !_Chain_Is_empty( header ) ) {
- switch ( direction ) {
- case WATCHDOG_BACKWARD:
- _Watchdog_First( header )->delta_interval += units;
- break;
- case WATCHDOG_FORWARD:
- while ( units ) {
- if ( units < _Watchdog_First( header )->delta_interval ) {
- _Watchdog_First( header )->delta_interval -= units;
- break;
- } else {
- units -= _Watchdog_First( header )->delta_interval;
- _Watchdog_First( header )->delta_interval = 1;
+ _Watchdog_First( header )->delta_interval += units;
+ }
+
+ _ISR_Enable( level );
+}
+
+void _Watchdog_Adjust_forward(
+ Chain_Control *header,
+ Watchdog_Interval units
+)
+{
+ ISR_Level level;
+
+ _ISR_Disable( level );
+
+ while ( !_Chain_Is_empty( header ) && units > 0 ) {
+ Watchdog_Control *first = _Watchdog_First( header );
- _ISR_Enable( level );
+ if ( units < first->delta_interval ) {
+ first->delta_interval -= units;
+ break;
+ } else {
+ units -= first->delta_interval;
+ first->delta_interval = 1;
- _Watchdog_Tickle( header );
+ _ISR_Enable( level );
- _ISR_Disable( level );
+ _Watchdog_Tickle( header );
- if ( _Chain_Is_empty( header ) )
- break;
- }
- }
- break;
+ _ISR_Disable( level );
}
}
_ISR_Enable( level );
-
}