From fbbe5fde57bdc9d0c7f809931c2addb43bc1bd42 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Fri, 18 Jul 2003 14:47:55 +0000 Subject: 2003-07-18 Till Straumann PR 430/rtems * include/rtems/score/watchdog.h: _Watchdog_Ticks_since_boot should be a VOLATILE variable. * src/watchdoginsert.c: 'restart' algorithm needs to enforce reloading the list head in case a TICK interrupt during ISR_Flash() modified the list. This is achieved by a proper VOLATILE cast. Also _Watchdog_Sync_count++ should be protected by _ISR_Disable (prevent corruption in case ISR calls watchdoginsert) * src/watchdogadjust.c: ISR protection added. * src/watchdogtickle.c: ISR protection added. NOTE: PowerPC BSPs using the new exception processing MUST BE UPDATED to maintain _ISR_Nest_level. See also PR288 which provides fixes for the affected BSPs distributed with RTEMS. --- cpukit/score/src/watchdogtickle.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'cpukit/score/src/watchdogtickle.c') diff --git a/cpukit/score/src/watchdogtickle.c b/cpukit/score/src/watchdogtickle.c index fe07f566ff..80b1784152 100644 --- a/cpukit/score/src/watchdogtickle.c +++ b/cpukit/score/src/watchdogtickle.c @@ -33,18 +33,32 @@ void _Watchdog_Tickle( Chain_Control *header ) { + ISR_Level level; Watchdog_Control *the_watchdog; + Watchdog_States watchdog_state; + + /* + * See the comment in watchdoginsert.c and watchdogadjust.c + * about why it's safe not to declare header a pointer to + * volatile data - till, 2003/7 + */ + + _ISR_Disable( level ); if ( _Chain_Is_empty( header ) ) - return; + goto leave; the_watchdog = _Watchdog_First( header ); the_watchdog->delta_interval--; if ( the_watchdog->delta_interval != 0 ) - return; + goto leave; do { - switch( _Watchdog_Remove( the_watchdog ) ) { + watchdog_state = _Watchdog_Remove( the_watchdog ); + + _ISR_Enable( level ); + + switch( watchdog_state ) { case WATCHDOG_ACTIVE: (*the_watchdog->routine)( the_watchdog->id, @@ -71,7 +85,13 @@ void _Watchdog_Tickle( case WATCHDOG_REMOVE_IT: break; } + + _ISR_Disable( level ); + the_watchdog = _Watchdog_First( header ); } while ( !_Chain_Is_empty( header ) && (the_watchdog->delta_interval == 0) ); + +leave: + _ISR_Enable(level); } -- cgit v1.2.3