Compartilhar via


CreateWatchDogTimer (Windows CE 5.0)

Send Feedback

This function creates a watchdog timer.

HANDLECreateWatchDogTimer(LPCWSTR pszWatchDogName,DWORD dwPeriod,DWORD dwWait,DWORD dwDfltAction,DWORD dwParam,DWORD dwFlags);

Parameters

  • pszWatchDogName
    [in] Name of the watchdog timer to be created. Each object type, such as memory maps, semaphores, events, message queues, mutexes, and watchdog timers, has its own separate namespace. Empty strings, "", are handled as named objects. On Windows desktop-based platforms, synchronization objects all share the same namespace.

  • dwPeriod
    [in] Watchdog period, in milliseconds.

  • dwWait
    [in] Time to wait, in milliseconds, when the watchdog timer is not refreshed within the watchdog period before the default action is taken.

    This is useful when handling false alarms or saving important information before system reset.

  • dwDfltAction
    [in] Default action to be taken when the watchdog timer is not refreshed within dwPeriod.

    The following values can be used to specify the default action to take.

    Value Description
    WDOG_NO_DFLT_ACTION Take no default action
    WDOG_KILL_PROCESS Terminate the process to be watched
    WDOG_RESET_DEVICE Reset the device by calling IOCTL_HAL_REBOOT
  • dwParam
    [in] Parameter to be passed to IOCTL_HAL_REBOOT.

    The OAL can use this information to determine if an immediate system reboot is needed or to perform a delayed system reboot.

  • dwFlags
    [in] Reserved; must be set this value to 0.

Return Values

A handle to the watchdog timer indicates success.

NULL indicates failure.

The returned handle can be used in WaitForSingleObject or WaitForMultipleObjects, and is signaled when the watchdog is not refreshed within the specified watchdog period, dwPeriod. Use the CloseHandle function to release the memory used by the watchdog timer.

If a watchdog timer of the given name exists, the handle to the existing watchdog timer is returned and GetLastError returns ERROR_ALREADY_EXISTS.

Remarks

Watchdog is used to make sure critical processes are running as expected. Typically, every critical process creates a watchdog timer and refreshes it by calling the RefreshWatchDogTimer function from time to time to determine that the watchdog is working correctly.

You can create a monitor process to wait on the watchdog handles to perform actions when the critical processes fail to signal the watchdog timers.

If the critical process fails to refresh its watchdog timer within the watchdog period (specified by dwPeriod), the watchdog is signaled.

The monitor process, if it exists, has up to dwWait milliseconds to determine if it is a false alarm or save critical information before the default action is taken.

In case of a false alarm, the monitor process should refresh the watchdog to prevent the default action from being taken.

When the default action is taken, the watchdog is considered stopped. That is, the same watchdog timer is not signaled again until it is started again.

CreateWatchDogTimer is a trusted API because it gives you the ability to reset the device. Only trusted applications can access this function. For more information, see Trusted APIs.

Requirements

OS Versions: Windows CE 5.0 and later.
Header: Pkfuncs.h.
Link Library: Coredll.lib.

See Also

IOCTL_HAL_REBOOT | WaitForSingleObject | WaitForMultipleObjects | CloseHandle | OpenWatchDogTimer | StartWatchDogTimer | StopWatchDogTimer | RefreshWatchDogTimer | GetLastError

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.