summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/watchdogadjusttochain.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2009-07-09 21:56:34 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2009-07-09 21:56:34 +0000
commit744379eee379defb35620086e5cc6dd074554cb6 (patch)
tree8644ba9cd33e6eec39536c343148f7c5dd140f23 /cpukit/score/src/watchdogadjusttochain.c
parent2009-07-09 Joel Sherrill <joel.sherrill@OARcorp.com> (diff)
downloadrtems-744379eee379defb35620086e5cc6dd074554cb6.tar.bz2
2009-07-09 Joel Sherrill <joel.sherrill@OARcorp.com>
* score/src/watchdogadjusttochain.c: Rework to ease code coverage analysis.
Diffstat (limited to 'cpukit/score/src/watchdogadjusttochain.c')
-rw-r--r--cpukit/score/src/watchdogadjusttochain.c51
1 files changed, 31 insertions, 20 deletions
diff --git a/cpukit/score/src/watchdogadjusttochain.c b/cpukit/score/src/watchdogadjusttochain.c
index 5a03208ee0..6fedb9d0e1 100644
--- a/cpukit/score/src/watchdogadjusttochain.c
+++ b/cpukit/score/src/watchdogadjusttochain.c
@@ -4,7 +4,7 @@
* This is used by the Timer Server task.
*/
-/* COPYRIGHT (c) 1989-2008.
+/* COPYRIGHT (c) 1989-2009.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -31,36 +31,47 @@ void _Watchdog_Adjust_to_chain(
{
Watchdog_Interval units = units_arg;
ISR_Level level;
- Chain_Node *node;
-
- if ( !units ) {
+ Watchdog_Control *first;
+
+ if ( !units )
return;
- }
+
_ISR_Disable( level );
if ( !_Chain_Is_empty( header ) ) {
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 = 0;
+ first = _Watchdog_First( header );
- do {
- node = _Chain_Get_unprotected( header );
- _Chain_Append_unprotected( to_fire, node );
+ /*
+ * If it is longer than "units" until the first element on the chain
+ * fires, then bump it and quit.
+ */
+ if ( units < first->delta_interval ) {
+ first->delta_interval -= units;
+ break;
+ }
- _ISR_Flash( level );
+ /*
+ * The first set happens in less than units, so take all of them
+ * off the chain and adjust units to reflect this.
+ */
+ units -= first->delta_interval;
+ first->delta_interval = 0;
- } while ( !_Chain_Is_empty( header ) &&
- _Watchdog_First( header )->delta_interval == 0 );
+ while (1) {
+ _Chain_Extract_unprotected( &first->Node );
+ _Chain_Append_unprotected( to_fire, &first->Node );
- if ( _Chain_Is_empty( header ) )
- break;
+ _ISR_Flash( level );
+
+ if ( _Chain_Is_empty( header ) )
+ break;
+
+ first = _Watchdog_First( header );
+ if ( first->delta_interval != 0 )
+ break;
}
}
-
}
_ISR_Enable( level );
}