Xentara v2.0.4
User Manual
Configuring Realtime Linux

Under Linux, Xentara is capable of running realtime tasks. This requires some additional configuration in the operating system however.

Installing a Realtime Kernel

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:

$ uname -v
#1 SMP PREEMPT_RT Debian 6.1.90-1 (2024-05-03)

How to install an PREEMPT_RT kernel depends on the Linux distribution you are running. For the supported distributions, see instructions below.

Debian

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:

dpkg --list "linux-image-*"

The output will look something like this:

Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-================================-=============-============-==========================================================
ii linux-image-6.1.0-21-arm64 6.1.90-1 arm64 Linux 6.1 for 64-bit PCs (signed)
un linux-image-6.1.0-21-arm64-unsigned <keine> <keine> (no description available)
un linux-image-6.1.0-21-rt-arm64 6.1.90-1 arm64 Linux 6.1 for 64-bit PCs, PREEMPT_RT (signed)
un linux-image-6.1.0-21-rt-arm64-unsigned <keine> <keine> (no description available)
ii linux-image-arm64 6.1.90-1 arm64 Linux for 64-bit PCs (meta-package)
un linux-image-generic <keine> <keine> (no description available)
un linux-image-rt-arm64 6.1.90-1 arm64 Linux for 64-bit PCs (meta-package)

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:

sudo apt install linux-image-rt-arm64
Note
The user installing the kernel needs the privileges necessary to execute the sudo(8) command. This is usually accomplished by adding the user to the sudo user group. This can only be done by the root user, or by another user that already has sudo access.

Ubuntu

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

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.

Giving Xentara Realtime Privileges

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:

sudo usermod --append --groups realtime username

or:

sudo usermod -a -G realtime username

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:

sudo usermod --remove --groups realtime username

or:

sudo usermod -r -G realtime username
Note
The user executing these commands will need special privileges to be able to use sudo(8). This is usually accomplished by adding the user to the sudo user group. This can only be done by the root user, or by another user that already has sudo access.

Core Isolation

See also
CPU Affinity in Scheduling Tasks

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:

isolcpus=3 rcu_nocbs=3 rcu_nocb_poll

Multiple CPUs can be separated by commas:

isolcpus=14,15 rcu_nocbs=14,15 rcu_nocb_poll

CPUs can also be specified as ranges, using a dash:

isolcpus=60-63,124-127 rcu_nocbs=60-63,124-127 rcu_nocb_poll

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:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

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):

sudoedit /etc/defaults/grub

The desired kernel parameters should be added to the GRUB_CMDLINE_LINUX_DEFAULT variable:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash isolcpus=14,15 rcu_nocbs=14,15 rcu_nocb_poll"

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):

sudo update-grub

Since these are boot parameters, a reboot is required for the changes to take effect.

Note
The user performing these actions will need special privileges to be able to use sudoedit(8) and sudo(8). This is usually accomplished by adding the user to the sudo user group. This can only be done by the root user, or by another user that already has sudo access.