VxWorks includes a watchdog-timer mechanism that allows any C function to be connected to a specified time delay. Watchdog timers are maintained as part of the system clock ISR. Normally, functions invoked by watchdog timers execute as interrupt service code at the interrupt level of the system clock. However, if the kernel is unable to execute the function immediately for any reason (such as a previous interrupt or kernel state), the function is placed on the tExcTask work queue. Functions on the tExcTask work queue execute at the priority level of the tExcTask (usually 0). Restrictions on ISRs apply to routines connected to watchdog timers. The functions in Table 2-24 are provided by the wdLib library.
|
|||||||||||||||||||
|
|||||||||||||||||||
|
|||||||||||||||||||
A watchdog timer is first created by calling wdCreate( ). Then the timer can be started by calling wdStart( ), which takes as arguments the number of ticks to delay, the C function to call, and an argument to be passed to that function. After the specified number of ticks have elapsed, the function is called with the specified argument. The watchdog timer can be canceled any time before the delay has elapsed by calling wdCancel( ).
/* This example creates a watchdog timer and sets it to go off in * 3 seconds. */