title: WinAPI Sleep() function call sleeps for longer than expected
body: <p>OS: Windows 7</p>
  
  <p>When calling the WinAPI Sleep() function as Sleep(1) the thread actually sleeps for 15ms. I did it 100 times in a loop and the total sleep time was 1500ms instead of 100.</p>
  
  <p>Is this common behavior or should I be concerced about something being wrong with my MOBO, CPU, Windows installion?</p>
  
  <p>EDIT: If possible could you run this code and post how long the sleep time was. I let a friend of mine run this, and he actually had it all at 1ms.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;ctime&gt;
  #include &lt;Windows.h&gt;
  
  void test(void)
  {
      std::cout &lt;&lt; "Testing 1ms sleep." &lt;&lt; std::endl;
  
      for (unsigned int i = 0; i &lt; 10; i++)
      {
          std::clock_t startClocks = std::clock();
  
          Sleep(1);
  
          std::clock_t clocksTaken = std::clock() - startClocks;
          std::cout &lt;&lt; "Time: " &lt;&lt; clocksTaken &lt;&lt; "ms." &lt;&lt; std::endl;
      }
  }
  
  int main(void)
  {
      test();
  
      std::cin.sync();
      std::cin.get();
      return 0;
  }
  </code></pre>
  
  <p>EDIT2: It seems that the reason why some people are getting 1ms is that some other program is running that sets the system-wide timer resolution to 1ms. By default this should be 15.6ms on Windows 7. </p>