According to https://rt.wiki.kernel.org/index.php/RT_PREEMPT_HOWTO , the RT-Preempt patch converts Linux into a fully preemptible kernel. The magic is done by:

  1. Making in-kernel locking-primitives (using spinlocks) preemptible though reimplementation with rtmutexes.
  2. Critical sections protected by i.e. spinlock_t and rwlock_t are now preemptible. The creation of non-preemptible sections (in kernel) is still possible with raw_spinlock_t (same APIs like spinlock_t)
  3. Implementing priority inheritance for in-kernel mutexes, spinlocks and rw_semaphores.
  4. Converting interrupt handlers into preemptible kernel threads: The RT-Preempt patch treats soft interrupt handlers in kernel thread context, which is represented by a task_struct like a common userspace process. However it is also possible to register an IRQ in kernel context.
  5. Converting the old Linux timer API into separate infrastructures for high resolution kernel timers plus one for timeouts, leading to userspace POSIX timers with high resolution.

Are there any drawbacks of being real-time instead of just multi-tasking?


The -rt (RT-Preempt) kernel patch is not in the kernel mainline because the Linux Kernel is focused on the implementation of a kernel for general use, and multi-tasking was a choice from Linus Torvalds when he began implementing it.

It is curious why the kernel is the way it is. The answer is that it is the way it is because Linus chose this way. And why he chose this way? Because he belived it was the better way, or the achievable way of implementing it.

Some people think that others design concepts is better than the actual one. But it is impossible to say that. Each one has its own opinion, and sometimes there is no way of benchmark comparison due to the complexity and possibilities.

There is the classical discussion between Linus Torvalds and Andrew Tanenbaum about monolithic versus microkernel. And there is many arguments to say that each one is a better model.

The same way, there is multi-tasking and real-time. Which one is better? Each one has its own advantages and drawbacks.

All in all, mainline kernel does not comes patched to be real time. Simple! This is just because of developer's choices and beliefs!

  • "It's that way because Linus wanted it that way" is kind of a non-answer. The OP is wanting to know why Linus would have decided to do that. This question is likely to inspire partially opinion-based answers though. – Bratchley Apr 29 '14 at 0:10
  • I consider this 'quote' a kind of analogy for understanding a point of view. For technical background, I suggest **studying de debate here. I'd like just to emphasize that the OP wants to know 'Why isn't the -rt (RT-Preempt) kernel patch included by default in the mainline kernel'. – vitorafsr Apr 29 '14 at 0:42

This is going to opinion based, so do take it for what it is worth.

Any engineering decision is about balancing trade-off. The -rt patch is about determinism in handling timing. It is about getting certain that things will execute at the right time. Remember the old saying:

real-time is when the right answer at the wrong time is wrong

But typical usage is not about real time. Vanilla Linux is good enough in this area for typical usage, so it does not need the -rt patch. Using the -rt patch, the system will instead most probably be slower for a typical usage.

As -rt does not add anything useful for the typical user, decreases typical workload performance, it is not included in the usual kernel distributions.

There definetely are uses for the -rt patch, so it is very good that it is included as a standard part of the kernel source code. It now is simply a choice to make when building the kernal (there are a lot of choices available in various areas when building a kernal). If your workload is improved by the -rt patch, do select a kernal that has it enabled (or build it yourself specifically tailored to your situation).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.