source: rtems/cpukit/score/src/watchdogadjusttochain.c @ 632e4306

4.104.115
Last change on this file since 632e4306 was 744379e, checked in by Joel Sherrill <joel.sherrill@…>, on 07/09/09 at 21:56:34

2009-07-09 Joel Sherrill <joel.sherrill@…>

  • score/src/watchdogadjusttochain.c: Rework to ease code coverage analysis.
  • Property mode set to 100644
File size: 1.7 KB
Line 
1/**
2 *  @file watchdogadjusttochain.c
3 *
4 *  This is used by the Timer Server task.
5 */
6
7/*  COPYRIGHT (c) 1989-2009.
8 *  On-Line Applications Research Corporation (OAR).
9 *
10 *  The license and distribution terms for this file may be
11 *  found in the file LICENSE in this distribution or at
12 *  http://www.rtems.com/license/LICENSE.
13 *
14 *  $Id$
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/system.h>
22#include <rtems/score/isr.h>
23#include <rtems/score/watchdog.h>
24
25void _Watchdog_Adjust_to_chain(
26  Chain_Control               *header,
27  Watchdog_Interval            units_arg,
28  Chain_Control               *to_fire
29
30)
31{
32  Watchdog_Interval  units = units_arg;
33  ISR_Level          level;
34  Watchdog_Control  *first;
35 
36  if ( !units )
37    return;
38 
39  _ISR_Disable( level );
40
41  if ( !_Chain_Is_empty( header ) ) {
42    while ( units ) {
43      first = _Watchdog_First( header );
44
45      /*
46       *  If it is longer than "units" until the first element on the chain
47       *  fires, then bump it and quit.
48       */
49      if ( units < first->delta_interval ) {
50        first->delta_interval -= units;
51        break;
52      }
53
54      /*
55       *  The first set happens in less than units, so take all of them
56       *  off the chain and adjust units to reflect this.
57       */
58      units -= first->delta_interval;
59      first->delta_interval = 0;
60
61      while (1) {
62        _Chain_Extract_unprotected( &first->Node );
63        _Chain_Append_unprotected( to_fire, &first->Node );
64
65      _ISR_Flash( level );
66   
67        if ( _Chain_Is_empty( header ) )
68          break;
69
70        first = _Watchdog_First( header );
71        if ( first->delta_interval != 0 )
72          break;
73      }
74    }
75  }
76  _ISR_Enable( level );
77}
78
Note: See TracBrowser for help on using the repository browser.