title: Is it possible to eliminate jitter from a Linux machine when running a simple single-threaded C++ program?
body: <p>I am performing various experiments with an Ubuntu box running kernel 3.5.7. I <em>warmup</em> my benchmark code to 10 million iterations and then proceed to time 90 million iterations. Still I see the following jitter:</p>
  
  <pre><code>Average: 242 nanos | Min Time: 230 nanos | Max Time: 4717 nanos  
  0.75 = avg: 240, max: 246  
  0.9 = avg: 241, max: 247  
  0.99 = avg: 242, max: 250  
  0.999 = avg: 242, max: 251  
  0.9999 = avg: 242, max: 517  
  0.99999 = avg: 242, max: **2109** &lt;===  
  0.999999 = avg: 242, max: **3724** &lt;===  
  0.9999999 = avg: 242, max: **4424** &lt;===
  </code></pre>
  
  <p>I see bad times on 0.01% of my iterations. Is it possible to make a Linux kernel really real-time? Is there something else happening in the kernel that I can't control?</p>
  
  <pre><code>for(int i = 0; i &lt; iterations; i++) {
  
      long start = get_nano_ts(&amp;ts);
  
      for(int j = 0; j &lt; load; j++) {
          long p = (i % 8) * (i % 16);
          if (i % 2 == 0) {
              x += p;
          } else {
              x -= p;
          }
      }
  
      long end = get_nano_ts(&amp;ts);
  
      int res = end - start;
  
      // store the results, calculate the percentiles, averages, min, max, etc.
  }
  </code></pre>