title: Time running backwards with QueryPerformanceCounter()
body: <p>I have found useful information regarding the use of QueryPerformanceCounter in <a href="https://stackoverflow.com/questions/1739259/how-to-use-queryperformancecounter">this post</a> but I am facing an issue for which I have not found an answer. </p>
  
  <p>I am developing an application for Windows CE 6.0 and need a better resolution that GetTickCount can offer. That is why I chose QueryPerformanceCounter function. </p>
  
  <p>I have observed that the counter value I get goes back and forth. Although it is not the final application this little example ilustrates the problem:</p>
  
  <pre><code>int i;
  BOOL bRet;
  LARGE_INTEGER liCounter;
  
  
  for ( i = 0; i &lt; 100; i++)
  {
      bRet = QueryPerformanceCounter(&amp;liCounter);
      if(bRet)
      {
          printf("Counter Value: %llu \n", liCounter.QuadPart);
      }
  
  }
  </code></pre>
  
  <p>It prints a series of 100 counter values which are expected to be incremental. However, there are some counter values which decrement with respect to the previous value. For example:</p>
  
  <p>...</p>
  
  <p>Counter Value: 6536266821</p>
  
  <p>Counter Value: 6536266<strong>262</strong></p>
  
  <p>Counter Value: 6536266604</p>
  
  <p>...</p>
  
  <p>This behaviour is problematic since in the final application (endCounterValue-startCoutnerValue) type operations are carried out and negative time intervals are found in same cases.</p>
  
  <p>I have read (<a href="http://www.virtualdub.org/blog/pivot/entry.php?id=106" rel="nofollow noreferrer">here</a>) this problem can be found when using multicore platforms. However, this is not the case since Windows CE 6.0 does not support multicore processing. </p>
  
  <p>Any help to find a reason why does this happen and/or any workaround to avoid this problem would be appreciated. </p>
  
  <p>[Edit]</p>
  
  <p>I edit the question in order to include more information:</p>
  
  <p>A longer list of consecutive reads (different from the list above):</p>
  
  <p>Counter Value: 15234261579 </p>
  
  <p>Counter Value: 15234261594 </p>
  
  <p>Counter Value: 15234261609 </p>
  
  <p>Counter Value: 15234261624 </p>
  
  <p>Counter Value: 15234261640 </p>
  
  <p><strong>Counter Value: 15234261064</strong> </p>
  
  <p>Counter Value: 15234261079 </p>
  
  <p>Counter Value: 15234261094 </p>
  
  <p>Counter Value: 15234261109 </p>
  
  <p>Counter Value: 15234261125 </p>
  
  <p>Counter Value: 15234261140 </p>
  
  <p>Counter Value: 15234261155 </p>
  
  <p>Counter Value: 15234261170 </p>
  
  <p>Counter Value: 15234261185 </p>
  
  <p>Counter Value: 15234261201 </p>
  
  <p>Counter Value: 15234261216 </p>
  
  <p>Counter Value: 15234261231 </p>
  
  <p>Counter Value: 15234261246 </p>
  
  <p>Regarding the hardware, an Intel Celeron 1047UE processor and HM76 chipset are being used. </p>
  
  <p>When calling to QueryPerformanceFrequency, 1.19MHz frequency is read. </p>