Skip to content

Commit 79a6bf3

Browse files
committed
docs: Added notes and graphs on real-time optimizations
1 parent c4cf46a commit 79a6bf3

15 files changed

+111
-17
lines changed

ReadMe.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Docker real-time guide for `PREEMPT_RT`
44

5-
Author: [Tobit Flatscher](https://github.com/2b-t) (August 2021 - September 2022)
5+
Author: [Tobit Flatscher](https://github.com/2b-t) (August 2021 - February 2023)
66

77

88

@@ -23,7 +23,7 @@ This can be useful for several different applications, in particular:
2323
- **Numerical control** by turning your desktop or single-board computer into a SoftPLC e.g. with [CodeSYS Control](https://www.codesys.com/products/codesys-runtime/control.html) or using [LinuxCNC](http://linuxcnc.org/)
2424
- **Real-time programming in audio development** such as with [Juce](https://juce.com/discover/stories/real-time-programming-in-audio-development)
2525

26-
but may also apply to software developers developing any other form of real-time capable code.
26+
but may also apply to software developers developing any other form of real-time capable code. This guide does not apply to Windows and Macintosh operating systems as it relies on a `PREEMPT_RT`-patched host system.
2727

2828

2929

@@ -97,7 +97,10 @@ Then **any process from inside the Docker can set real-time priorities `rtprio`*
9797

9898
## 2. Example
9999

100-
This Github repository comes with a simple example that can be used to try it out. Inside the Docker container a [`cyclictest`](https://wiki.linuxfoundation.org/realtime/documentation/howto/tools/cyclictest/start) is run to assess the real-time performance of the system. You can compare the outcome to running it on your local system. There should be virtually no difference between the two.
100+
This Github repository comes with a simple example that can be used to try it out. Inside the Docker container a [`cyclictest`](https://wiki.linuxfoundation.org/realtime/documentation/howto/tools/cyclictest/start) is run to assess the real-time performance of the system. You can compare the outcome to running it on your local system. There should be virtually no difference between the two, as can be seen from the graphs below:
101+
102+
| ![On host operating system](media/p500_cstates_off.png) | ![Inside Docker](media/p500_docker_cstates_off.png) |
103+
| ------------------------------------------------------- | --------------------------------------------------- |
101104

102105
For launching the `cyclictest` open the Docker by typing
103106

doc/realtime_basics/PreemptRt.md

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# `PREEMPT_RT` set-up
22

3-
Author: [Tobit Flatscher](https://github.com/2b-t) (August 2021 - April 2022)
3+
Author: [Tobit Flatscher](https://github.com/2b-t) (August 2021 - February 2023)
44

55
## 1. Setting-up `PREEMPT_RT`
66

@@ -96,7 +96,19 @@ and **generate a new configuration** `.config` file with
9696
$ make oldconfig
9797
```
9898

99-
Go ahead and **change the relevant configuration parameters** if you want to. This can be done graphically with `$ make xconfig`, `$ make menuconfig` or manually by modifying the `.config` file located inside `linux-${KERNEL_VER_FULL}`. The [German Open Source Automation Development Lab (OSADL) ](https://www.osadl.org/) performs long-term tests on several kernel versions and publishes the results on the internet. One might want to use these parameters instead rather than working with his/her own `.config` file. An overview of the corresponding systems can be found [here](https://www.osadl.org/Real-time-optimization.qa-farm-latency-optimization.0.html) and the configuration file for a particular system can be downloaded (e.g. [this one](https://www.osadl.org/?id=1087#kernel)).
99+
Go ahead and **change the relevant configuration parameters** if you want to. This can be done graphically with `$ make xconfig`, `$ make menuconfig` or manually by modifying the `.config` file located inside `linux-${KERNEL_VER_FULL}`. The [German Open Source Automation Development Lab (OSADL) ](https://www.osadl.org/) performs long-term tests on several kernel versions and publishes the results on the internet. One might want to use these parameters instead rather than working with his/her own `.config` file. An overview of the corresponding systems can be found [here](https://www.osadl.org/Real-time-optimization.qa-farm-latency-optimization.0.html) and the configuration file for a particular system can be downloaded (e.g. [this one](https://www.osadl.org/?id=1087#kernel)). If you set incompatible flags they might be reset later on. As soon as the kernel compilation starts **check the `.config` file if your desired settings are still set** or if they were implicitly discarded. If you want to see what the configuration of your current kernel looks like [type `$ cat /boot/config-$(uname -r)` in your console](https://www.baeldung.com/linux/kernel-config).
100+
101+
I personally generally use the following settings:
102+
103+
```shell
104+
# Find and replace
105+
CONFIG_HZ_1000=y # Requires to comment the other entries such as CONFIG_HZ=250
106+
CONFIG_HZ=1000
107+
CONFIG_NO_HZ_IDLE=y
108+
CONFIG_NO_HZ=y
109+
CONFIG_HIGH_RES_TIMERS=y
110+
CONFIG_CPU_ISOLATION=y
111+
```
100112

101113
For a successful installation I have to change the following parameters inside the `.config` file:
102114

doc/realtime_basics/RealTimeLinux.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ When talking about real-time kernels one differentiates between single kernel ap
1616

1717
### 2.1 Dual kernel real-time Linux
1818

19-
**Dual kernel** approaches predate single-kernel ones by several years. In this case a **separate real-time micro-kernel runs in parallel to the traditional Linux kernel**. The real-time code is given priority over the user space which is only allowed to run if no real-time code is executed. The following two dual-kernel approaches are commonly used:
19+
**Dual kernel** approaches predate single-kernel ones by several years. In this case a **separate real-time micro-kernel runs in parallel to the traditional Linux kernel**. The real-time code is given priority over the [user space](https://ubuntu.com/blog/industrial-embedded-systems) which is only allowed to run if no real-time code is executed. The following two dual-kernel approaches are commonly used:
2020

2121
- **RTAI** (Real-time Application Interface) was developed by the Politecnico di Milano. One has to program in kernel space instead of the user space and therefore can't use the standard C libraries but instead must use special libraries that do not offer the full functionality of its standard counterparts. The interaction with the user space is handled over special interfaces, rendering programming much more difficult. New drivers for the micro-kernel have to be developed for new hardware making the code always lack slightly behind. For commercial codes also licensing might be an issue as kernel modules are generally licensed under the open-source Gnu Public License (GPL).
2222
- With the **Xenomai** real-time operating system it has been tried to improve the separation between kernel and user space. The programmer works in user space and then abstractions, so called skins are added that emulate different APIs (e.g. that implement a subset of Posix threads) which have to be linked against when compiling.

0 commit comments

Comments
 (0)