source: rtems/cpukit/score/src/watchdogadjusttochain.c @ c86da31c

4.115
Last change on this file since c86da31c was 28352fae, checked in by Ralf Corsepius <ralf.corsepius@…>, on 11/29/09 at 13:51:53

Whitespace removal.

  • 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 <= 0 ) {
37    return;
38  }
39
40  _ISR_Disable( level );
41
42  while ( 1 ) {
43    if ( units <= 0 ) {
44      break;
45    }
46    if ( _Chain_Is_empty( header ) ) {
47      break;
48    }
49    first = _Watchdog_First( header );
50
51    /*
52     *  If it is longer than "units" until the first element on the chain
53     *  fires, then bump it and quit.
54     */
55    if ( units < first->delta_interval ) {
56      first->delta_interval -= units;
57      break;
58    }
59
60    /*
61     *  The first set happens in less than units, so take all of them
62     *  off the chain and adjust units to reflect this.
63     */
64    units -= first->delta_interval;
65    first->delta_interval = 0;
66
67    while ( 1 ) {
68      _Chain_Extract_unprotected( &first->Node );
69      _Chain_Append_unprotected( to_fire, &first->Node );
70
71      _ISR_Flash( level );
72
73      if ( _Chain_Is_empty( header ) )
74        break;
75      first = _Watchdog_First( header );
76      if ( first->delta_interval != 0 )
77        break;
78    }
79  }
80
81  _ISR_Enable( level );
82}
83
Note: See TracBrowser for help on using the repository browser.