<br><br><div class="gmail_quote">On Wed, Feb 2, 2011 at 3:07 PM, David T. Lewis <span dir="ltr">&lt;<a href="mailto:lewis@mail.msen.com">lewis@mail.msen.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">&gt;<br>
&gt; Or some concurrency issue, because hearbeat runs in separate thread<br>
&gt; than vm thread.<br>
<br>
</div>Hmmm... That&#39;s a thought. This is a complete shot in the dark, but the<br>
following does not look thread safe to me:<br>
<br>
  static void<br>
  high_performance_tick_handler(int sig, struct siginfo *sig_info, void *context)<br>
  {<br>
  static int tickCheckInProgress;<br>
<br>
          if (tickCheckInProgress) return;<br>
<br>
          tickCheckInProgress = 1;<br>
          checkHighPriorityTickees(ioUTCMicroseconds());<br>
          tickCheckInProgress = 0;<br>
  }<br>
<br>
This should be using a mutex, no?<br></blockquote><div><br></div><div>Indeed it doesn&#39;t look thread-safe, and it isn&#39;t, but it doesn&#39;t need to be.  It is a signal handler whose sigaction does not contain SA_NODEFER and so it cannot be reentered since the OS guarantees not to deliver the signal until any previous instance of the handler has returned.  Hence CAS is unnecessary, but a good comment isn&#39;t :)  I&#39;ll try and comment it here rather than where the sigaction is established:</div>
<div><br></div><div><div>    ticker_handler_action.sa_sigaction = high_performance_tick_handler;</div><div>    /* N.B. We _do not_ include SA_NODEFER to specifically prevent reentrancy</div><div>     * during the heartbeat. We /must/ include SA_RESTART to avoid issues with</div>
<div>     * e.g. ODBC connections.</div><div>     */</div><div>    ticker_handler_action.sa_flags = SA_RESTART | SA_ONSTACK;</div><div>    sigemptyset(&amp;ticker_handler_action.sa_mask);</div><div>    if (sigaction(TICKER_SIGNAL, &amp;ticker_handler_action, 0)) {</div>
<div>        perror(&quot;ioInitHeartbeat sigaction&quot;);</div><div>        exit(1);</div><div>    }</div></div><div><br></div><div>best</div><div>Eliot</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<br>
Dave<br>
<br>
</blockquote></div><br>