title: How to improve real-time performance of 1ms timer in Linux?
body: <p>I'm working on an embedded Linux project, using an arago distribution that is probably around version 3.3.</p>
  
  <p>I have configured a high-resolution Linux timer to wake-up my process once per millisecond. This works ok but there are two issues with the timing:</p>
  
  <ol>
  <li>A jitter in the wake-up time</li>
  <li>Variability of the processing time when awake, despite the fact that the processing done by the process is constant.</li>
  </ol>
  
  <p>I attribute these problems to the less-than real-time performance of Linux.  But I need to
  investigate ways of improving the real-time performance. </p>
  
  <p>I have checked that the kernel is configured with the CONFIG_PREEMPT kernel option, which is good for real-time.</p>
  
  <p>I have also applied the SCHED_FIFO scheduling class to my process:</p>
  
  <pre><code>struct sched_param schedparm;
  memset(&amp;schedparm, 0, sizeof(schedparm));
  schedparm.sched_priority = 1; // lowest rt priority
  sched_setscheduler(0, SCHED_FIFO, &amp;schedparm);
  </code></pre>
  
  <p>but that made no difference.</p>
  
  <p>I guess that a logical step is to apply the PREEMPT_RT patch to the kernel build, but I haven't identified how to do that yet.</p>
  
  <p>Is there anything else I can do to improve the jitter / duration variability?</p>
  
  <p>Or can anyone suggest an accessible tutorial on how to apply the PREEMPT_RT patch?</p>