1

In my understanding, we can change kernel's scheduling behavior in some way; changing scheduler itself, or setting nice value to a process. These can be used to make processes hold processor core longer time.

On the other hand, there is a PREEMPT_RT patch to make Linux kernel closer to realtime system.

What is different between them from realtime system's perspective?

In my understanding, using schedulers other than Linux CFS, they can make processes to use processor core longer time, but they don't support process preemption. However, PREEMPT_RT patch make kernel to support preemption and prioritization, it is usually better to make kernel closer to realtime system.

Is my understanding correct?

hidetatz
  • 195
  • 8

1 Answers1

2

Well, you're on the right track, although this is a pretty big topic, probably too big for a stackoverflow answer. But a few points that hopefully help you get started:

  • Both in "normal" Linux and PREEMPT_RT, user space processes are preemptible. That's how the OS gives you the illusion of hundreds of processes running on a few (or even a single) CPU core. The difference is that in PREEMPT_RT, much more of the kernel code itself is also preemptible. There are still some places even in PREEMPT_RT where kernel preemption is disabled, but these places are as few and as short as possible. One of the main ways this is done is that in PREEMPT_RT all interrupt handlers run in their own kernel threads, managed by the scheduler. This allows e.g. a high-priority user-space process to have higher priority than a kernel thread. See e.g. What is the difference between threaded interrupt handler and tasklet? for the difference between threaded interrupt handlers and the softirq's/tasklets that the normal kernel uses extensively.

  • In PREEMPT_RT, many of the kernel locks are converted to variants supporting priority inheritance, a common real-time programming feature to avoid a condition called "priority inversion".

  • Even with the PREEMPT_RT, depending on how you want to define it, Linux is not a "hard real-time" OS, as Linux is far too big and complex to be analyzed by formal methods.

For an overview of PREEMPT_RT see https://lwn.net/Articles/146861/ . Although that article is more than 15 years at this point and many of the details have changed, the fundamental principles and issues remain.

janneb
  • 36,249
  • 2
  • 81
  • 97
  • Thank you. It seems like their purpose are different so I need a closer look to apply to the production system. I'll also take a look at the article. Thank you again! – hidetatz Mar 30 '23 at 01:54