<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'Need a good method for thread monitoring' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'Need a good method for thread monitoring' posted on the 'Embedded / RTOS' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Wed, 19 Jun 2013 15:52:14 -0700</pubDate>
    <lastBuildDate>Wed, 19 Jun 2013 15:52:14 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>Need a good method for thread monitoring</title>
      <link>http://www.programmersheaven.com/mb/embedded/414429/414429/need-a-good-method-for-thread-monitoring/</link>
      <description>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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Currently, I have implemented a method where another monitor thread for process A is created and the two threads interact as such (pseudocode):&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;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."
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Is there a better way to implement thread monitoring?&lt;br /&gt;
&lt;br /&gt;
-Nick&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/embedded/414429/414429/need-a-good-method-for-thread-monitoring/</guid>
      <pubDate>Thu, 11 Mar 2010 06:05:10 -0700</pubDate>
      <category>Embedded / RTOS</category>
    </item>
  </channel>
</rss>