3 ms·
Almost all of the original PREEMPT_RT patchset are mainlined now, but the features are not (all) enabled by default. Low latency will always present a tradeoff
by PaulDavisThe1st 5y ago
Almost all of the original PREEMPT_RT patchset are mainlined now, but the features are not (all) enabled by default. Low latency will always present a tradeoff with bandwidth, and Linux is used for so many different purposes that one is not clearly more important than the other.
For more than 10 years, Linux with the PREEMPT_RT patch has been capable of more-or-less hard real time, with latencies in the 10's of usecs range. That can be thwarted, however, by a variety of hardware features (SMI being the worst offender, plus devices that hog the PCI bus for too long), so you are not guaranteed this performance just by running that kernel.
- zamadatix 5y agoDumb question inbound are those features boot/runtime toggable or compile time options?
- PaulDavisThe1st 5y agoCompile time.
- snvzz 5y ago>more-or-less hard real time Also known as soft realtime. For hard realtime, you need guarantees. Linux is too complex and cannot possibly offer them; this is the territory of formal proof, with complexity growing exponentially with code size. Look at seL4 for hard realtime.
- PaulDavisThe1st 5y agoEven with the "guarantees" offered by e.g. seL4, you still need cooperating hardware. SMIs on most mobos cannot be masked, and can take an eternity to be handled by the BIOS. Fortunately, for realtime audio, you don't need hard realtime unless you're very close to overloading the CPUs. Soft realtime (i.e. 99% of all interrupts handled within N usecs, 100% handled with N*2) is good enough.
- jeffreygoesto 5y agoRight. Also for hard realtime with 100% deadline guarantees (absence of soft and programming errors assumed, for a second) you would choose an appropriate CPU like the ARM Cortex-R series. You'd also take care of the peripherals, i.e. choose 801.2AS or even Flexray.
- zurn 5y ago100% handled with N*2 would be hard realtime.
- kbumsik 5y agoNo. Soft real time can miss some real time deadline. AFAIK Linux RT kernel is designed to hit every deadline, but they just cannot offer a formal proof. So "more-or-less" hard real time.
- ComputerGuru 5y agoOne of the problems is that the Linux RT kernel doesn’t stop you from using/writing devices/drivers that break those guarantees systemwide, as I understand it.
- colonwqbang 5y agoWhat kernel can give such a guarantee?
- dspillett 5y agoOne that has no such drivers? Which would then imply limited hardware support as the price for the guarantee, which is a trade-off a general purpose kernel like Linux isn't going to make.
- _flux 5y agoA microkernel one, potentially at least.
- lloeki 5y agoA kernel alone on a random hardware platform can't, but a kernel and a hardware core that watchdogs and flips the bird at a rt-violating driver+device, sure (I've toyed with VxWorks on devices that work this way). Usually when you're entering that realm of such requirements, you're rarely talking about off-the-shelf devices.
- snvzz 5y agoseL4[0]. I'm not aware of any other. [0]: https://sel4.systems/ https://sel4.systems/
- snvzz 5y ago
- jcelerier 5y agoLinux has the ability of entirely freeing a few CPU cores with isolcpus though, so that you can implement your own real-time loop on it
- snvzz 5y agoSure. And you can also run an RTOS on a separate chip, elsewhere on the same PCB. Linux is still Linux, and it is still fundamentally not capable of hard realtime.
- viraptor 5y agoIf anyone wants to try the as-much-rt-as-possible build in a nice ready package, there's the Xanmod project https://xanmod.org/ https://xanmod.org/ which offers it precompiled with a few other tweaks. It's aimed at gamer crowd, but I had a really good experience using it with music processing.
- PaulDavisThe1st 5y agoThe default xanmod kernel is still not using the PREEMPT_RT features. They do note that "Real-time Linux kernel (PREEMPT_RT) build available [5.10-rt]." and that's how you get "as much RT as possible". The features in the normal version of their kernel will improve the user experience of latency, but will not address "realtime" in the way that PREEMPT_RT does.
- viraptor 5y agoCorrect, the 5.12 versions don't have the PREEMPT patches, you'll need the 5.10-rt version.