title: nanosleep high cpu usage?
body: <p>I noticed that a little test program which calls nanosleep is showing a huge difference in CPU usage when run on Linux machines with a kernel newer than 2.6.22.</p>
  
  <pre><code>#include &lt;time.h&gt;
  int main (void)
  {
      struct timespec sleepTime;
      struct timespec returnTime;
      sleepTime.tv_sec = 0;
      sleepTime.tv_nsec = 1000;
      while (1)
      {
        nanosleep(&amp;sleepTime, &amp;returnTime);
      }
      return 0;
  }
  </code></pre>
  
  <p>(Yes, I realise this program does nothing)</p>
  
  <p>If I compile this and run it on an openSUSE 10.3 machine (2.6.22.19-0.2-default), the program does not even show up on the process list generated by "top", indicating to me that it is using very little CPU time.  If I run it on an openSUSE 11.1 machine (2.6.27.23-0.1-default), top shows the program taking 40% of the CPU time.  Running on Fedora 9 (2.6.25-14.fc9.i686) and Fedora 10 also showed the same high CPU usage in "top".</p>
  
  <p>Has there been a change in the kernel that affects this?</p>