📄 wdtecos.c
字号:
/***************************************************************** * * * wdtecos.c * * * * This file is a part of the eXtremeDB-HA Application Framework * * It demonstrates McObject High Availabitity support and * * explains how to work with it. * * * ***************************************************************** * Copyright (c) 2001-2006 McObject LLC * * All Rights Reserved * *****************************************************************//* * ++ * * PROJECT: Ha Framework * * SUBSYSTEM: HA support * * MODULE: wdtecos.c * * ABSTRACT: WATCHDOG asynchron processing procedures for HA support * * * VERSION: 1.0 * * HISTORY: * 1.0- 1 Vlad Artemiev 21-Aug-2006 Created it was * * -- */#ifdef _ECOS#include <cyg/kernel/kapi.h>//#include <stdlib.h>//#include <stdio.h>//#include <time.h>#include "watchdog.h"static cyg_handle_t alarmid;static long ticks = 0;static char init = 0;static char disabled = 0;extern uint4 ECOS_Ticks_Per_Second;void mco_ecos_init_clock();#define MS_TO_TICKS(ms) ((ms * ECOS_Ticks_Per_Second) / 1000)#define WDT_REACTIVATE() \ cyg_alarm_initialize(alarmid, cyg_current_time() + ticks, ticks);\ if (disabled){\ cyg_alarm_enable(alarmid);\ disabled = 0;\ }void ecos_alrm_func(cyg_handle_t alrm,MCO_PWATCHDOG proc){ if (proc) proc();}int mco_create_watchdog( long msec, MCO_PWATCHDOG proc){ cyg_handle_t counter,rclocks; cyg_alarm alarm; if (!init){ rclocks = cyg_real_time_clock(); cyg_clock_to_counter(rclocks,&counter); cyg_alarm_create(counter, (cyg_alarm_t*) ecos_alrm_func, (cyg_addrword_t)proc, &alarmid, &alarm); init = 1; } if (!ECOS_Ticks_Per_Second) mco_ecos_init_clock(); ticks = MS_TO_TICKS(msec); WDT_REACTIVATE(); return 0;}void mco_kill_watchdog( long msec, MCO_PWATCHDOG proc){ if (init && !disabled){ cyg_alarm_disable(alarmid); disabled = 1; }}#endif /* _ECOS */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -