Xentara v2.0.4
User Manual
|
Under Linux, Xentara is capable of running realtime tasks. This requires some additional configuration in the operating system however.
The regular mainline Linux kernel does not provide the necessary timing guarantees to execute realtime tasks. To enable realtime tasks, the running kernel must have the PREEMPT_RT patch applied. These kernels usually include the rt in their version, e.g. 6.1.0-21-rt. You can check whether the running kernel contains the PREEMPT_RT patch by running t command uname -v in a terminal. If the output contains the string “PREEMPT_RT”, then the PREEMPT_RT patch is present:
How to install an PREEMPT_RT kernel depends on the Linux distribution you are running. For the supported distributions, see instructions below.
Under Debian, kernels, including PREEMPT_RT kernels, can be installed using apt(8). In order to do this, you must first determine the exact kernel package installed on your host, as this might vary from hardware to hardware. To determine the kernel installed, run the following command:
The output will look something like this:
Installed packages are marked with “ii”, and uninstalled packages with “un”. The packages also come in two varieties, ones that include a version number in the name, like “linux-image-6.1.0-21-arm64”, and others without, like “linux-image-arm64”. The packages without version numbers are so called “meta-packages”, and just automatically select the latest kernel version.
To determine which kernels are installed, look for the meta-package (without version number) that starts with the text “ii”. The corresponding PREEMPT_RT kernel will have the same name, but with the infix “-rt-”. In the example above, the installed kernel meta-package is “linux-image-arm64”, and the corresponding PREEMPT_RT package is thus “linux-image-rt-arm64”.
Install the relevant PREEMPT_RT kernel meta-package using the apt(8) utility. In the above example, the correct command would be:
Ubuntu does not make PREEMPT_RT available in its regular distribution. To use the kernel under Ubuntu, you need to use Real-time Ubuntu, available under https://ubuntu.com/real-time.
Raspberry Pi OS is based on Debian, but uses its own custom kernel. Raspberry Pi OS does not provide a PREEMPT_RT variant of its kernel, however. For realtime operations, you can instead use the regular Debian distribution for Raspberry Pi, available at raspi.debian.net.
Alternatively, you can build an PREEMPT_RT version of the Raspberry Pi OS kernel youself as described here in the Raspberry Pi Documentation. This is only recommended for users with experience in building Linux kernels, however.
Xentara requires special privileges to be able to apply some of the optimizations needed to run realtime tasks. If you run Xentara using the provided systemd Service, then the necessary privileges are automatically granted, and no further action is needed.
If you want to run Xentara from the command line, or from a script not started by systemd(1), then the user running Xentara must be given the necessary privileges. The Xentara installation package automatically creates a user group called realtime, that has the required privileges. You can add any user to this group using the usermod(8) system tool. To add a user called username to the realtime group, for example, execute the following command:
or:
Do not foget the –append or -a option, or the user will be removed from all other groups he/she already belong to. The user will have to log out and log back it for changes to take effect.
To remove the user from the group, use the following command:
or:
In order to take maximum advantage of Xentara’s realtime capabilities, realtime tasks can be executed on dedicated CPU cores reserved for these tasks. To do this, the Linux kernel must be instructed to isolate these CPU cores, so that no other programs or kernel tasks will run on them. Isolating CPUs must be done at boot time by the boot loader, by passing the parameters isolcpus, rcu_nocbs, and (optionally), rcu_nocb_poll to the kernel. To isolate CPU 3, for example, the following kernel parameters must be added to the boot loader:
Multiple CPUs can be separated by commas:
CPUs can also be specified as ranges, using a dash:
CPU numbers start at 0, so that a four core CPU will have CPU numbers 0, 1, 2, and 3.
The boot loader on modern Linux installation is generally GNU GRUB. The configuration for the kernel parameters for grub can be found in the file /etc/defaults/grub. This file contains a variable GRUB_CMDLINE_LINUX_DEFAULT, that specifies the command line options to be passed to the kernel during a normal boot:
Your installation may have slightly different parameters. The full documentation for /etc/defaults/grub can be found under in chapter 6.1 Simple configuration handling in the GNU GRUB Manual.
The grub defaults file can only be modified by root, and is therefore best edited using sudoedit(8):
The desired kernel parameters should be added to the GRUB_CMDLINE_LINUX_DEFAULT variable:
You should generally not modify the existing kernel parameters, just add the required parameters to the end. The complete documentation for the Linux kernel parameters can be found here.
After modifying these files, the boot loader configuration must be regenerated using update-grub(8):
Since these are boot parameters, a reboot is required for the changes to take effect.