summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/watchdogremove.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2015-04-24 09:53:58 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2015-05-19 12:00:43 +0200
commitfd53d2514e8869dd5ddb5fd5a72f6f443840cca8 (patch)
tree97e99e3b87a8a1c3e36b04f8984c839d329d8d88 /cpukit/score/src/watchdogremove.c
parentscore: Add Watchdog_Iterator (diff)
downloadrtems-fd53d2514e8869dd5ddb5fd5a72f6f443840cca8.tar.bz2
score: Move _Watchdog_Tickle()
Make internal function _Watchdog_Remove_it() static to avoid accidental usage. Update #2307.
Diffstat (limited to 'cpukit/score/src/watchdogremove.c')
-rw-r--r--cpukit/score/src/watchdogremove.c67
1 files changed, 66 insertions, 1 deletions
diff --git a/cpukit/score/src/watchdogremove.c b/cpukit/score/src/watchdogremove.c
index c896fbb00f..2ac63fe998 100644
--- a/cpukit/score/src/watchdogremove.c
+++ b/cpukit/score/src/watchdogremove.c
@@ -21,7 +21,7 @@
#include <rtems/score/watchdogimpl.h>
#include <rtems/score/assert.h>
-void _Watchdog_Remove_it(
+static void _Watchdog_Remove_it(
Watchdog_Header *header,
Watchdog_Control *the_watchdog
)
@@ -107,3 +107,68 @@ Watchdog_States _Watchdog_Remove(
_Watchdog_Release( header, &lock_context );
return( previous_state );
}
+
+void _Watchdog_Tickle(
+ Watchdog_Header *header
+)
+{
+ ISR_lock_Context lock_context;
+
+ _Watchdog_Acquire( header, &lock_context );
+
+ if ( !_Watchdog_Is_empty( header ) ) {
+ Watchdog_Control *first;
+ Watchdog_Interval delta;
+
+ first = _Watchdog_First( header );
+ delta = first->delta_interval;
+
+ /*
+ * Although it is forbidden to insert watchdogs with a delta interval of
+ * zero it is possible to observe watchdogs with a delta interval of zero
+ * at this point. For example lets have a watchdog chain of one watchdog
+ * with a delta interval of one and insert a new one with an initial value
+ * of one. At the start of the insert procedure it will advance one step
+ * and reduce its delta interval by one yielding zero. Now a tick happens.
+ * This will remove the watchdog on the chain and update the insert
+ * iterator. Now the insert operation continues and will insert the new
+ * watchdog with a delta interval of zero.
+ */
+ if ( delta > 0 ) {
+ --delta;
+ first->delta_interval = delta;
+ }
+
+ while ( delta == 0 ) {
+ bool run;
+ Watchdog_Service_routine_entry routine;
+ Objects_Id id;
+ void *user_data;
+
+ run = ( first->state == WATCHDOG_ACTIVE );
+
+ _Watchdog_Remove_it( header, first );
+
+ routine = first->routine;
+ id = first->id;
+ user_data = first->user_data;
+
+ _Watchdog_Release( header, &lock_context );
+
+ if ( run ) {
+ (*routine)( id, user_data );
+ }
+
+ _Watchdog_Acquire( header, &lock_context );
+
+ if ( _Watchdog_Is_empty( header ) ) {
+ break;
+ }
+
+ first = _Watchdog_First( header );
+ delta = first->delta_interval;
+ }
+ }
+
+ _Watchdog_Release( header, &lock_context );
+}