Is it possible to eliminate jitter from a Linux machine when running a simple single-threaded program in C ++?

I am doing various experiments with the Ubuntu kernel with the launch of the 3.5.7 kernel. I warm up my control code to 10 million iterations, and then move on to 90 million iterations. However, I see the following jitter:

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** <=== 0.999999 = avg: 242, max: **3724** <=== 0.9999999 = avg: 242, max: **4424** <=== 

I see bad times at 0.01% of my iterations. Is it possible to make the Linux kernel really real-time? Is there anything else in the kernel that I cannot control?

 for(int i = 0; i < iterations; i++) { long start = get_nano_ts(&ts); for(int j = 0; j < load; j++) { long p = (i % 8) * (i % 16); if (i % 2 == 0) { x += p; } else { x -= p; } } long end = get_nano_ts(&ts); int res = end - start; // store the results, calculate the percentiles, averages, min, max, etc. } 
+8
c ++ performance optimization benchmarking real-time
source share
1 answer

The short answer is no. You will have to throw away everything else that the kernel provides to ensure that your code receives a 100% duty cycle.

If you want a guaranteed monopoly on the CPU, you need to use a real-time operating system that allows you to disable all interrupts. Something like FreeRTOS or VXWorks.

A coreless core is designed to save standby power. It is not intended to completely disable interrupts. All I / O devices constantly require interrupts. If you turned off all I / O drivers and ran without restrictions and turned off all services that might wake up periodically, you can get closer to work without jitter. But then you will have a brick.

+6
source share

All Articles