Introduction

Hi Folks! It’s been a while since I wrote a post here. But my blog is not dead, it was just sleeping for a while. :) Now, I’d like to get my first impressions on how to work with a realtime Linux kernel.

Many asks why do you need a realtime kernel at all? Well, in an average use case, you don’t need a realtime kernel. For me, it is needed to realize realtime control of hardware. For this, I also need realtime processing of data.

One word about the spelling. You can find real time, real-time or realtime in the literature (or in the Internet) as well. I’ll try to use realtime all the time in these (hopefully multiple) blog posts. If you have reasons to write it differently, please contact me, I’ll correct.

What is realtime?

There are some article about what is realtime in the computer system sense and what subcategories there are (hard or soft realtime etc.). I don’t want to go into much details, but if you are interested, Wikipedia has a quite good summary. (If you can find better ones, then please send me and I’ll put them here as well. ;) ) The main thing is, that in a realtime environment, you have to get answers from the system in a well-defined time-frame (one way or another).

I found a few description/tutorials about this topic, I share them here without any guarantee or quality check.

  1. Real-time Control Systems: A Tutorial
  2. Fundamentals of real-time processing in automation and control
  3. Real-time control systems: A Tutorial
  4. Real-Time Systems
  5. Real-Time Control System and Real-Time Networks (The full lecture is here.)

However, in this post I mainly concern realtime kernels in Linux systems, which are ensure this kind of behaviour from the kernel side.

Realtime testing

Here is a few sources I found about realtime kernel testing.

  1. Real-Time Testing Best Practices
  2. RT-Tests
  3. Real-time Linux materials
  4. Real-time Linux Communications (And the paper on Arxiv.)
  5. Red Hat Linux realtime kernel material

Realtime kernels in Linux distributions

There are Linux distributions with realtime kernel packages (e.g. Manjaro Linux or CentOS 7 or Rocky Linux 8). Interestingly enough, Ubuntu does not provide (to my knowledge) an out-of-the-box realtime kernel by default. You have to patch your desired kernel to show realtime capabilities. So in the next section I’ll look into that matter.

The other possibility (which I will describe in details in the overnext section) is to use low-latency kernel. This is not exactly realtime, but can provide significantly lower response time in the kernel (0.1 ms according to this source. It also mentions a few security considerations for a realtime kernel.).

How to patch Ubuntu kernel to have realtime properties

According to this Stackoverflow post, it can be done without much pain. However, until I try it myself, I just link the documentation here. When I’ll have some own experience with this, I’ll go into the details.

How to install Ubuntu low-latency kernel

This is much easier than the realtime kernel patching, since there is a package ready for install. I use Ubuntu 20.04 (focal). The package can be found in the package index here.