summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/watchdogremove.c
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/score/src/watchdogremove.c')
-rw-r--r--cpukit/score/src/watchdogremove.c71
1 files changed, 56 insertions, 15 deletions
diff --git a/cpukit/score/src/watchdogremove.c b/cpukit/score/src/watchdogremove.c
index c765ac55c7..c896fbb00f 100644
--- a/cpukit/score/src/watchdogremove.c
+++ b/cpukit/score/src/watchdogremove.c
@@ -18,9 +18,58 @@
#include "config.h"
#endif
-#include <rtems/system.h>
-#include <rtems/score/isr.h>
#include <rtems/score/watchdogimpl.h>
+#include <rtems/score/assert.h>
+
+void _Watchdog_Remove_it(
+ Watchdog_Header *header,
+ Watchdog_Control *the_watchdog
+)
+{
+ Chain_Node *next;
+ Watchdog_Interval delta;
+ const Chain_Node *iterator_tail;
+ Chain_Node *iterator_node;
+
+ _Assert(
+ the_watchdog->state == WATCHDOG_ACTIVE
+ || the_watchdog->state == WATCHDOG_REMOVE_IT
+ );
+
+ the_watchdog->state = WATCHDOG_INACTIVE;
+ the_watchdog->stop_time = _Watchdog_Ticks_since_boot;
+
+ next = _Chain_Next( &the_watchdog->Node );
+ delta = the_watchdog->delta_interval;
+
+ if ( next != _Chain_Tail( &header->Watchdogs ) ) {
+ Watchdog_Control *next_watchdog;
+
+ next_watchdog = (Watchdog_Control *) next;
+ next_watchdog->delta_interval += delta;
+ }
+
+ _Chain_Extract_unprotected( &the_watchdog->Node );
+
+ iterator_node = _Chain_First( &header->Iterators );
+ iterator_tail = _Chain_Immutable_tail( &header->Iterators );
+
+ while ( iterator_node != iterator_tail ) {
+ Watchdog_Iterator *iterator;
+
+ iterator = (Watchdog_Iterator *) iterator_node;
+
+ if ( iterator->current == next ) {
+ iterator->delta_interval += delta;
+ }
+
+ if ( iterator->current == &the_watchdog->Node ) {
+ iterator->current = _Chain_Previous( &the_watchdog->Node );
+ }
+
+ iterator_node = _Chain_Next( iterator_node );
+ }
+}
Watchdog_States _Watchdog_Remove(
Watchdog_Header *header,
@@ -29,7 +78,7 @@ Watchdog_States _Watchdog_Remove(
{
ISR_lock_Context lock_context;
Watchdog_States previous_state;
- Watchdog_Control *next_watchdog;
+ Watchdog_Interval now;
_Watchdog_Acquire( header, &lock_context );
previous_state = the_watchdog->state;
@@ -44,24 +93,16 @@ Watchdog_States _Watchdog_Remove(
* the Insert operation we interrupted will be aborted.
*/
the_watchdog->state = WATCHDOG_INACTIVE;
+ now = _Watchdog_Ticks_since_boot;
+ the_watchdog->start_time = now;
+ the_watchdog->stop_time = now;
break;
case WATCHDOG_ACTIVE:
case WATCHDOG_REMOVE_IT:
-
- the_watchdog->state = WATCHDOG_INACTIVE;
- next_watchdog = _Watchdog_Next( the_watchdog );
-
- if ( _Watchdog_Next(next_watchdog) )
- next_watchdog->delta_interval += the_watchdog->delta_interval;
-
- if ( _Watchdog_Sync_count )
- _Watchdog_Sync_level = _ISR_Nest_level;
-
- _Chain_Extract_unprotected( &the_watchdog->Node );
+ _Watchdog_Remove_it( header, the_watchdog );
break;
}
- the_watchdog->stop_time = _Watchdog_Ticks_since_boot;
_Watchdog_Release( header, &lock_context );
return( previous_state );