source: rtems/cpukit/score/src/watchdogadjusttochain.c @ 6d253941

4.115
Last change on this file since 6d253941 was 6d253941, checked in by Sebastian Huber <sebastian.huber@…>, on 04/15/15 at 14:28:42

score: Add _Watchdog_Acquire|Release|Flash()

Update #2307.

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief Watchdog Adjust to Chain
5 *  @ingroup ScoreWatchdog
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2009.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/score/watchdogimpl.h>
22#include <rtems/score/isrlevel.h>
23
24void _Watchdog_Adjust_to_chain(
25  Watchdog_Header   *header,
26  Watchdog_Interval  units_arg,
27  Chain_Control     *to_fire
28
29)
30{
31  Watchdog_Interval  units = units_arg;
32  ISR_lock_Context   lock_context;
33  Watchdog_Control  *first;
34
35  _Watchdog_Acquire( header, &lock_context );
36
37  while ( 1 ) {
38    if ( _Watchdog_Is_empty( header ) ) {
39      break;
40    }
41    first = _Watchdog_First( header );
42
43    /*
44     *  If it is longer than "units" until the first element on the chain
45     *  fires, then bump it and quit.
46     */
47    if ( units < first->delta_interval ) {
48      first->delta_interval -= units;
49      break;
50    }
51
52    /*
53     *  The first set happens in less than units, so take all of them
54     *  off the chain and adjust units to reflect this.
55     */
56    units -= first->delta_interval;
57    first->delta_interval = 0;
58
59    while ( 1 ) {
60      _Chain_Extract_unprotected( &first->Node );
61      _Chain_Append_unprotected( to_fire, &first->Node );
62
63      _Watchdog_Flash( header, &lock_context );
64
65      if ( _Watchdog_Is_empty( header ) )
66        break;
67      first = _Watchdog_First( header );
68      if ( first->delta_interval != 0 )
69        break;
70    }
71  }
72
73  _Watchdog_Release( header, &lock_context );
74}
75
Note: See TracBrowser for help on using the repository browser.