2
* This program is free software; you can redistribute it and/or modify
3
* it under the terms of the GNU General Public License as published by
4
* the Free Software Foundation; either version 2 of the License, or
5
* (at your option) any later version.
7
* This program is distributed in the hope that it will be useful,
8
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
* GNU General Public License for more details.
12
* You should have received a copy of the GNU General Public License
13
* along with this program; if not, write to the Free Software
14
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
* Author : Richard GAYRAUD - 04 Nov 2003
21
* Francois-Xavier Kowalski
23
* From Hewlett Packard Company.
28
* Guillaume Teissier from FTR&D
31
* Charles P Wright from IBM Research
35
void watchdog::dump() {
36
WARNING("Watchdog Task: interval = %d, major_threshold = %d (%d triggers left), minor_threshold = %d (%d triggers left)", interval, major_threshold, major_maxtriggers, minor_threshold, minor_maxtriggers);
39
watchdog::watchdog(int interval, int reset_interval, int major_threshold, int major_maxtriggers, int minor_threshold, int minor_maxtriggers) {
40
this->interval = interval;
41
this->reset_interval = reset_interval;
42
this->major_threshold = major_threshold;
43
this->major_maxtriggers = major_maxtriggers;
44
this->minor_threshold = minor_threshold;
45
this->minor_maxtriggers = minor_maxtriggers;
48
last_trigger = last_fire = getmilliseconds();
51
bool watchdog::run() {
53
if (last_fire + this->major_threshold < clock_tick) {
54
CStat::globalStat(CStat::E_WATCHDOG_MAJOR);
55
last_trigger = clock_tick;
56
WARNING("The major watchdog timer %dms has been tripped (%d), %d trips remaining.", major_threshold, clock_tick - last_fire, major_maxtriggers - major_triggers);
57
if ((this->major_maxtriggers != -1) && (++major_triggers > this->major_maxtriggers)) {
58
ERROR("The watchdog timer has tripped the major threshold of %dms too many times (%d out of %d allowed) (%d out of %d minor %dms timeouts tripped)\n", major_threshold, major_triggers, major_maxtriggers, minor_threshold, minor_triggers, minor_maxtriggers);
60
} else if (last_fire + this->minor_threshold < clock_tick) {
61
last_trigger = clock_tick;
62
CStat::globalStat(CStat::E_WATCHDOG_MINOR);
63
WARNING("The minor watchdog timer %dms has been tripped (%d), %d trips remaining.", minor_threshold, clock_tick - last_fire, minor_maxtriggers - minor_triggers);
64
if ((this->minor_maxtriggers != -1) && (++minor_triggers > this->minor_maxtriggers)) {
65
ERROR("The watchdog timer has tripped the minor threshold of %dms too many times (%d out of %d allowed) (%d out of %d major %dms timeouts tripped)\n", minor_threshold, minor_triggers, minor_maxtriggers, major_threshold, major_triggers, major_maxtriggers);
69
if (reset_interval && (major_triggers || minor_triggers) && (last_trigger + reset_interval < clock_tick)) {
70
WARNING("Resetting watchdog timer trigger counts, as it has not been triggered in over %dms.", clock_tick - last_trigger);
71
major_triggers = minor_triggers = 0;
74
last_fire = clock_tick;
79
unsigned int watchdog::wake() {
80
return last_fire + interval;