| Customize Help

Matrox Morphis Watchdog functionality

The Watchdog allows your MIL application to automatically recover from either application failure or some other type of critical situation. The Watchdog can automatically reboot your computer when, for some reason, your computer hangs for longer than a predetermined amount of time. In addition, the Watchdog permits a user-defined function to be attached (hooked) to a Watchdog warning. The Watchdog warning occurs when the Watchdog warning timer expires. This allows you to have two ways to recover (or at least be warned) from instabilities in your application.

Configuring the Watchdog

To configure the Watchdog, perform the following:

  1. Install the appropriate cables as described in the Matrox Morphis Installation and Hardware reference manual.

  2. Set the time that the Watchdog should wait before rebooting; use MsysControl() with M_WATCHDOG_REBOOT_TIMEOUT.

  3. Set the time that the Watchdog warning should wait before performing the specified hooked function; use MsysControl() with M_WATCHDOG_TIMEOUT. Note that if the Watchdog timeout is disabled, the warning timer will be ignored, and a Watchdog reboot timeout will trigger the reboot.

  4. To hook a function to handle the Watchdog event (which occurs when the warning timer expires), use MsysHookFunction() with M_WATCHDOG_WARNING.

  5. Enable the Watchdog, using MsysControl() with M_WATCHDOG_MODE set to M_ENABLE.

  6. Inside a processing loop, reset the Watchdog reboot timer and the Watchdog warning timer, using MsysControl() with M_WATCHDOG_RESET.

  7. The Watchdog also keeps a count of the number of times your computer reboots. Inquire the count using MsysInquire() with M_WATCHDOG_RESET_COUNTER. To reset the counter, use MsysControl() with M_WATCHDOG_RESET_COUNTER.

    The Watchdog will force a reboot if your computer hangs while rebooting or if the reboot process does not complete within a certain amount of time.


The following example shows how to configure and use the Watchdog. Note that exactly where you call the Watchdog within your application is highly situational.

/* Initialize the Watchdog by setting the required timeout values. */
MsysControl(MilSystem, M_WATCHDOG_REBOOT_TIMEOUT, 120 * 1000); // 2 min.
MsysControl(MilSystem, M_WATCHDOG_TIMEOUT, 30 * 1000);     // 30 sec.
/* Enable the Watchdog */
MsysControl(MilSystem, M_WATCHDOG_MODE, M_ENABLE);

/* While in a processing loop, somewhere in your application,
   you must send the command to reset the watchdog timer. */
  /* Place your application's processing loop here */
  /* Reset the Watchdog's timer.*/
  MsysControl(MilSystem, M_WATCHDOG_RESET, M_DEFAULT);
  } /* End the processing loop */