Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to improve real-time performance of 1ms timer in Linux?

I'm working on an embedded Linux project, using an arago distribution that is probably around version 3.3.

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:

  1. A jitter in the wake-up time
  2. Variability of the processing time when awake, despite the fact that the processing done by the process is constant.

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.

I have checked that the kernel is configured with the CONFIG_PREEMPT kernel option, which is good for real-time.

I have also applied the SCHED_FIFO scheduling class to my process:

struct sched_param schedparm;
memset(&schedparm, 0, sizeof(schedparm));
schedparm.sched_priority = 1; // lowest rt priority
sched_setscheduler(0, SCHED_FIFO, &schedparm);

but that made no difference.

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.

Is there anything else I can do to improve the jitter / duration variability?

Or can anyone suggest an accessible tutorial on how to apply the PREEMPT_RT patch?

like image 815
user1768576 Avatar asked Nov 13 '22 16:11

user1768576


1 Answers

It seems PREEMPT_RT is the logical next step. Did you try this tutorial?

https://rt.wiki.kernel.org/index.php/RT_PREEMPT_HOWTO

Update: I suggest you look at how others build a preemptive kernel, e.g. here: https://aur.archlinux.org/packages/linux-rt/

You can read the PKGBUILD to understand what is done.

like image 175
ypnos Avatar answered Nov 15 '22 11:11

ypnos