Watchdog implementation with single and multi thread

asked 2016-12-19 06:41:46 -0500

Randerson gravatar image

Hello all, I will start with a general question and according to the discussion evolution I will add more details about the issue I am facing.

The issue context is: I have a class implementation of a watchdog that kills the nodes that take more than a defined time to accomplish their tasks. In a simple test code, the class worked pretty well in a multi thread scenario (ros::AsyncSpinner) but it didn't work in the single thread one. Then, we I tried to use the class in the real code the result is worst, because neither the multi nor single thread worked. Now I specify what I mean with not working.

With the simple test code the watchdog instance was not capable of kill the application. It is like the callback time event was never called. Because o this I tried with multi treads.

With the real code, when trying to use the multi thread approach, the programs just crash and the message is prompt out of memory: Resource temporarily unavailable

For the second case, the error message is clear but it still doesn't some sense. What I mean is that it shouldn't happen because I can not see how the systems is without memory.

From this my question is: Why in the case of single thread the watchdog instance was not able to kill the application. Is it some single thread limitation? and what could I do to workaround this problem.


edit retag flag offensive close merge delete