全部博文(28)
分类: LINUX
2014-04-29 14:14:20
Honestly, I hate the terms "Hard real-time" and "Soft real-time.” How hard is hard? I used to work for Lockheed Martin, and there we did have the classic "hard real-time". Basically that's for a small component, which is part of a bigger component, but you can test every branch that the software on that component can take. It ends up being a custom piece of software, even when you start out with something like VxWorks. Probably the best real-time OS was DOS, because you can customize it to whatever requirements you need.
But once the software needs to handle a more general situation, it grows out of being mathematically provable. Then you start to lose that classic "Hard" real-time everyone talks about. There's a lot of systems out there that call themselves "Hard" real-time, where they probably would not meet these requirements.
For those that need hard real-time, it’s usually to control something that will end up killing people if something goes wrong. Everything else pretty much does not need that classic "Hard" real-time OS.
That said, PREEMPT_RT gives you something that's very close. I will be the first to tell you that I wouldn't want the PREEMPT_RT kernel to be controlling whether or not the plane I'm flying on crashes. But it's good enough for robotics, stock exchanges, and for computers that have to interface with the "Hard" real-time software. PREEMPT_RT has been used on computers that have gone into space.
PREEMPT_RT is a "hardening" of Linux. It's far from mathematically provable, but if there's an unbounded latency that's in PREEMPT_RT, we consider that a bug, and work hard to fix it. Our goal is to make Linux as hard as possible. ;-) That's probably what they meant about Linux not being able to handle real-time, as the mainline Linux kernel is filled with unbounded latencies. With unbounded latencies comes non-deterministic behavior.
Mainline Linux can do things really fast most of the time, but every so often, you get that outlier that could cause a large delay. Ever see your mouse jitter? With a properly setup PREEMPT_RT kernel, your desktop experience can be made much smoother.
I said before that a lot of people want real-time when they don't really need it, and even fewer people need hard real-time when they think they need it. I gave a talk in Brazil once titled "Who needs Real Time Linux? (Not you!)", where I basically stated that it’s really a small niche of people that need real-time.
One place that PREEMPT_RT comes in handy is with musicians. They were our earliest testers. I asked one person who reported a bug to test a patch, and he asked me for some advice in applying it. I asked him if he was a computer programmer, and he replied, "No, I'm a guitarist". He told me that the RT patch was great for getting reliable recordings, as jitter from mainline Linux would cause a scratching sound. I thought it was really cool that non computer focused people had a use for our work.