Ralph Mason <masonralph_at_yahoo_dot_com@thisisnotarealaddress .com> wrote:
That can be quite hard.
In the end, it all depends on what _exactly_ you want the dog to watch
out for: complete breakdown of multi-tasking (i.e. one task hangs in a
loop and no others get any CPU time) only, or partial breakdown too,
as in: task-switching is still being done, but at least one task is
getting executed too infrequently to get its work done.
It also depends rather strongly on the exact type of scheduling
algorithm you're using, esp. on whether the scheduler tries to
guarantee a maximum interval between invocations of a given thread, at
a given priority.
And it depends on what your watchdog time-out handler will *do*, once
it's triggered.
Putting it in the idle thread is not reliable at all --- it won't be
updated at all if the other threads are so busy that the idle thread
hardly ever gets executed at all. So the WD might well misfire in the
exact situation where it hurts most.
Putting it in the highest-priority thread will only detect complete
break-down of task-switching. It won't notice if some of the
medium-priority tasks are overloaded, but the top-priority one still
gets executed.
You may have to put the WD update into *every* thread instead. Or,
since you appear to be writing your own scheduler, right into the
scheduler itself. E.g. at each task switch for a task that has to finish
its next invocation before some known time interval, it should update
the watchdog to fire at that time if it's currently set to fire later.
--
Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.