After 20 years, Real-Time Linux (PREEMPT_RT) is finally – finally – in the mainline kernel. Linus Torvalds blessed the code while he was at Open Source Summit Europe. […] The real-time Linux code is now baked into all Linux distros as of the forthcoming Linux 6.12 kernel. This means Linux will soon start appearing in more mission-critical devices and industrial hardware. But it took its sweet time getting here. An RTOS is a specialized operating system designed to handle time-critical tasks with precision and reliability. Unlike general-purpose operating systems like Windows or macOS, an RTOS is built to respond to events and process data within strict time constraints, often measured in milliseconds or microseconds. As Steven Rostedt, a prominent real-time Linux developer and Google engineer, put it, “Real-time is the fastest worst-case scenario.” He means that the essential characteristic of an RTOS is its deterministic behavior. An RTOS guarantees that critical tasks will be completed within specified deadlines. […]

So, why is Real-Time Linux only now completely blessed in the kernel? “We actually would not push something up unless we thought it was ready,” Rostedt explained. “Almost everything was usually rewritten at least three times before it went into mainline because we had such a high bar for what would go in.” In addition, the path to the mainline wasn’t just about technical challenges. Politics and perception also played a role. “In the beginning, we couldn’t even mention real-time,” Rostedt recalled. “Everyone said, ‘Oh, we don’t care about real-time.’” Another problem was money. For many years funding for real-time Linux was erratic. In 2015, the Linux Foundation established the Real-Time Linux (RTL) collaborative project to coordinate efforts around mainlining PREEMPT_RT.

The final hurdle for full integration was reworking the kernel’s print_k function, a critical debugging tool dating back to 1991. Torvalds was particularly protective of print_k --He wrote the original code and still uses it for debugging. However, print_k also puts a hard delay in a Linux program whenever it’s called. That kind of slowdown is unacceptable in real-time systems. Rostedt explained: “Print_k has a thousand hacks to handle a thousand different situations. Whenever we modified print_k to do something, it would break one of these cases. The thing about print_k that’s great about debugging is you can know exactly where you were when a process crashed. When I would be hammering the system really, really hard, and the latency was mostly around maybe 30 microseconds, and then suddenly it would jump to five milliseconds.” That delay was the print_k message. After much work, many heated discussions, and several rejected proposals, a compromise was reached earlier this year. Torvalds is happy, the real-time Linux developers are happy, print_K users are happy, and, at long last, real-time Linux is real.

    • BCsven@lemmy.ca
      link
      fedilink
      arrow-up
      2
      ·
      53 minutes ago

      My guess is not a whole lot to the average user, but it would allow for things to still respond when other things have bogged down resources. I am assuming real world applications would be industry like a machine safery stop should always have a quick turn around, and not be delayed by harddrive writes. But may like how they write special OS code for spacecraft where sending and receiving instructions on board has special states and if response isn’t given in timely manner the system can recognize, so malfunctions are prevented. There was an artivle/podcast somewhere abouy how this all had to work in realtime and not be queued waiting

    • Admiral Patrick@dubvee.orgOP
      link
      fedilink
      English
      arrow-up
      11
      ·
      6 hours ago

      Probably some use cases for “regular” users. Someone mentioned music production, though that’s probably more professional than hobby.

      To my understanding, you mostly need real time performance for specialty cases where timing is absolutely critical. So I guess if you were building custom drones or custom control boards for drones, you could use real time Linux for that now since the timing could be guaranteed.

      • moody@lemmings.world
        link
        fedilink
        arrow-up
        3
        ·
        6 hours ago

        So what about 3D printing? Currently, input shaping uses an accelerometer to calculate resonances and uses that data to adjust movement and reduce flaws in the printing process. For anyone with knowledge of both fields, would this allow a built-in or add-on accelerometer to be used in real time to compensate for momentum and resonances even further?

        • RustyWizard@programming.dev
          link
          fedilink
          arrow-up
          1
          ·
          4 hours ago

          What’s preventing that from working now? If it’s indeterminate latency, then yeah, absolutely. Theoretically this will give you the ability to have a very deterministic loop around the accelerometer data, but 3d printers don’t move all that fast to begin with so having unbounded latency might not matter. The determinism we’re talking about here is on the order of tens of microseconds or less.

          • scutiger@lemmy.world
            link
            fedilink
            arrow-up
            2
            ·
            4 hours ago

            3D printers can move very fast. They typically don’t because it causes all kinds of deformations in the print. Mostly the issues are in acceleration, decelaration, cornering, and controlling the heat snd flow of melting filament.

            I don’t know whether or not the accelerometer thing can be done in real time, or if there would be any benefit.

            Check out the 2-minute Benchy for an example of how fast a 3D printer can get. This is a test print that typically should take about 45 minutes to an hour at very basic settings.

            But also note the quality of the end product. It looks pretty awful. If we could print accurately at even remotely similar speeds, it would be fantastic.

            • RustyWizard@programming.dev
              link
              fedilink
              arrow-up
              1
              ·
              3 hours ago

              “Very fast” is relative. 1200mm/s is very fast for 3D printing, no argument. But it’s 1.2mm/millisecond, and we’re talking about time scales in the microsecond range. I suspect you’re going to run into materials issues far before real time performance becomes a limiting factor in print speed and quality.