source: rtems/cpukit/score/src/watchdogtickle.c @ 62181b21

4.115
Last change on this file since 62181b21 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 3.5 KB
Line 
1/*
2 *  Watchdog Handler
3 *
4 *
5 *  COPYRIGHT (c) 1989-1999.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 */
12
13#if HAVE_CONFIG_H
14#include "config.h"
15#endif
16
17#include <rtems/system.h>
18#include <rtems/score/isr.h>
19#include <rtems/score/watchdog.h>
20
21/*
22 *  _Watchdog_Tickle
23 *
24 *  This routine decrements the delta counter in response to a tick.  The
25 *  delta chain is updated accordingly.
26 *
27 *  Input parameters:
28 *    header - pointer to the delta chain to be tickled
29 *
30 *  Output parameters: NONE
31 */
32
33void _Watchdog_Tickle(
34  Chain_Control *header
35)
36{
37  ISR_Level level;
38  Watchdog_Control *the_watchdog;
39  Watchdog_States  watchdog_state;
40
41  /*
42   * See the comment in watchdoginsert.c and watchdogadjust.c
43   * about why it's safe not to declare header a pointer to
44   * volatile data - till, 2003/7
45   */
46
47  _ISR_Disable( level );
48
49  if ( _Chain_Is_empty( header ) )
50    goto leave;
51
52  the_watchdog = _Watchdog_First( header );
53
54  /*
55   * For some reason, on rare occasions the_watchdog->delta_interval
56   * of the head of the watchdog chain is 0.  Before this test was
57   * added, on these occasions an event (which usually was supposed
58   * to have a timeout of 1 tick would have a delta_interval of 0, which
59   * would be decremented to 0xFFFFFFFF by the unprotected
60   * "the_watchdog->delta_interval--;" operation.
61   * This would mean the event would not timeout, and also the chain would
62   * be blocked, because a timeout with a very high number would be at the
63   * head, rather than at the end.
64   * The test "if (the_watchdog->delta_interval != 0)"
65   * here prevents this from occuring.
66   *
67   * We were not able to categorically identify the situation that causes
68   * this, but proved it to be true empirically.  So this check causes
69   * correct behaviour in this circumstance.
70   *
71   * The belief is that a race condition exists whereby an event at the head
72   * of the chain is removed (by a pending ISR or higher priority task)
73   * during the _ISR_Flash( level ); in _Watchdog_Insert, but the watchdog
74   * to be inserted has already had its delta_interval adjusted to 0, and
75   * so is added to the head of the chain with a delta_interval of 0.
76   *
77   * Steven Johnson - 12/2005 (gcc-3.2.3 -O3 on powerpc)
78   */
79  if (the_watchdog->delta_interval != 0) {
80    the_watchdog->delta_interval--;
81    if ( the_watchdog->delta_interval != 0 )
82      goto leave;
83  }
84
85  do {
86     watchdog_state = _Watchdog_Remove( the_watchdog );
87
88     _ISR_Enable( level );
89
90     switch( watchdog_state ) {
91       case WATCHDOG_ACTIVE:
92         (*the_watchdog->routine)(
93           the_watchdog->id,
94           the_watchdog->user_data
95         );
96         break;
97
98       case WATCHDOG_INACTIVE:
99         /*
100          *  This state indicates that the watchdog is not on any chain.
101          *  Thus, it is NOT on a chain being tickled.  This case should
102          *  never occur.
103          */
104         break;
105
106       case WATCHDOG_BEING_INSERTED:
107         /*
108          *  This state indicates that the watchdog is in the process of
109          *  BEING inserted on the chain.  Thus, it can NOT be on a chain
110          *  being tickled.  This case should never occur.
111          */
112         break;
113
114       case WATCHDOG_REMOVE_IT:
115         break;
116     }
117
118     _ISR_Disable( level );
119
120     the_watchdog = _Watchdog_First( header );
121   } while ( !_Chain_Is_empty( header ) &&
122             (the_watchdog->delta_interval == 0) );
123
124leave:
125   _ISR_Enable(level);
126}
Note: See TracBrowser for help on using the repository browser.