Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Need a good method for thread monitoring

nrundlenrundle Posts: 1Member
A fairly large RTOS application I'm working on uses a command pattern for communications between processes. That is, if process A needs to invoke a function in process B, then A creates a command and puts that into a queue. Then a separate command thread in process A executes that command which involves making a CORBA call to invoke the function in process B.

During debugging it has been observed that sometimes these command threads become deadlocked awaiting on the distant process to finish. I am looking for a good method of monitoring these command threads and at a minimum logging when they deadlock and perhaps even recovering from such a situation.

Currently, I have implemented a method where another monitor thread for process A is created and the two threads interact as such (pseudocode):

[code]commandThreadFunction()
while (true)
command_queue.pop(command)
command_name = command.getName()
command_timeout = command.getTimeout()
monitor_thread_start.signal()
command.execute()
monitor_thread_done.signal()

monitorThreadFunction()
while (true)
monitor_thread_start.wait()
monitor_thread_done.wait(command_timeout)
if (timedout)
print "Error: " + command_name + " timed out executing."
[/code]

Is there a better way to implement thread monitoring?

-Nick
Sign In or Register to comment.