Hi Henrik,<br><br><div class="gmail_quote">On Fri, Aug 13, 2010 at 2:56 PM, Henrik Sperre Johansen <span dir="ltr">&lt;<a href="mailto:henrik.s.johansen@veloxit.no">henrik.s.johansen@veloxit.no</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
 <br>

  
    
    
  
  <div bgcolor="#ffffff" text="#000000">
    On 13.08.2010 23:14, <a href="mailto:commits@squeakvm.org" target="_blank">commits@squeakvm.org</a> wrote:
    <blockquote type="cite">
      <pre> 
Author: eliot
Date: 2010-08-13 14:14:21 -0700 (Fri, 13 Aug 2010)
New Revision: 2253

Modified:
   branches/Cog/platforms/unix/vm/sqUnixHeartbeat.c
Log:
Integrate Henrik Johansen&#39;s fix for the nanosleep call in the heartbeat.


Modified: branches/Cog/platforms/unix/vm/sqUnixHeartbeat.c
===================================================================
--- branches/Cog/platforms/unix/vm/sqUnixHeartbeat.c        2010-08-11 18:03:02 UTC (rev 2252)
+++ branches/Cog/platforms/unix/vm/sqUnixHeartbeat.c        2010-08-13 21:14:21 UTC (rev 2253)
@@ -607,6 +607,8 @@
                 struct timespec naptime = beatperiod;
 
                 while (nanosleep(&amp;naptime, &amp;naptime) == -1
+                        /* oversleeps can return tv_sec = -1 tv_nsec approx 999999999 */
+                        &amp;&amp; naptime.tv_sec &gt;= 0 /* avoid undoc&#39;ed oversleep behaviour */
                         &amp;&amp; (naptime.tv_sec &gt; 0 || naptime.tv_nsec &gt; MINSLEEPNS)) /*repeat*/
                         if (errno != EINTR) {
                                 perror(&quot;nanosleep&quot;);
</pre>
    </blockquote>
    To be finicky, it&#39;s not actually undocumented though, if I
    interpreted the man pages correctly :)<br>
    <a href="http://www.opengroup.org/onlinepubs/009695399/functions/nanosleep.html" target="_blank">http://www.opengroup.org/onlinepubs/009695399/functions/nanosleep.html</a><br>
    <a href="http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man2/nanosleep.2.html" target="_blank">http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man2/nanosleep.2.html</a><br>

    <span style="border-collapse:separate;color:rgb(0, 0, 0);font-family:&#39;Times New Roman&#39;;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;font-size:medium"><span style="font-family:Arial,Verdana,Helvetica,sans-serif;font-size:12px"><br>

        &quot;If the<span> </span><tt style="font-family:&#39;courier new&#39;,courier,monospace">rmtp</tt><span> </span>argument is non-NULL,
        the<i><tt style="font-family:&#39;courier new&#39;,courier,monospace">timespec</tt></i><span> </span>structure referenced by
        it is updated to contain the amount of time remaining in the
        interval (the requested time minus the time actually slept). &quot;<br>
        <br>
        Since it also specifies that the valid range for tv_nsec is 0 -
        999999999, a negative value for tv_sec is the only valid option
        when it has overslept before being interrupted.<br></span></span></div></blockquote><div><br></div><div>You&#39;re right.  When I speed-read &quot;<span class="Apple-style-span" style="font-family: Monaco, Courier, monospace; font-size: 12px; white-space: pre; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">If rmtp is non-NULL, the timespec </span><span class="Apple-style-span" style="font-family: Monaco, Courier, monospace; font-size: 12px; white-space: pre; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">structure it references is updated to contain the unslept amount (the request time minus the time actu</span><span class="Apple-style-span" style="font-family: Monaco, Courier, monospace; font-size: 12px; white-space: pre; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">ally slept).</span>&quot; I ignored &quot;<span class="Apple-style-span" style="font-family: Monaco, Courier, monospace; font-size: 12px; white-space: pre; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">the request time minus the time actu</span><span class="Apple-style-span" style="font-family: Monaco, Courier, monospace; font-size: 12px; white-space: pre; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">ally slept</span>&quot; and assumed it would not return a negative amount.  I&#39;ll change the code.</div>
<div><br></div><div>thanks again,</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;"><div bgcolor="#ffffff" text="#000000"><span style="border-collapse:separate;color:rgb(0, 0, 0);font-family:&#39;Times New Roman&#39;;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;font-size:medium"><span style="font-family:Arial,Verdana,Helvetica,sans-serif;font-size:12px">
        <br>
        Cheers,<br>
        Henry<br>
      </span></span>
  </div>

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