'Is it possible to use core i7 for hard real-time OS?
Some people say the processor is "too smart", so you never know what time will it take to execute some sequence of instructions. I think you always have MIN and MAX time for any instruction and may use the MAX time for your time calculations.
Solution 1:[1]
Short answer: it' not possible a core i7 it's not designed for hard real time
Longer version: the problem it's not the unknown execution time it's that the whole processor it's not designed for real time take interrupts for example in an hard real time application you would use tons of interrupts because polling can add unwanted latency to the system but x64 has a real primitive interrupt handling system not only the performance of isr is sluggish at best due to huge context switch overhead but it lacks a lot of features like interrupt priority that let's you control the fine details of how interrupts are dealt with
You have to take into account also where hard real time os are needed that is in control systems for things like nuclear plants/aircrafts etc... in these environements a microcontroller is a lot better since there is not an single central control system but rather a network of smaller systems working together in a networked (canbus for example) fashion
In the end even if (and it's a huge if) you succeded in writing an hard real time os for intel i7 it would have performances so low that it would not be used
It's like tring to plant a nail with a screwdriver it could maybe be done but there is a reason in anyone use a hammer...
Solution 2:[2]
I don't know about the Core i7 in particular, but there is a concept of "worst case execution time" or WCET. You can get tools that will estimate it for you. I say "estimate" because its a difficult business to work out given the range of memory latencies, cache behaviours, instruction pipelines and so on. I haven't used these tools, but I suspect that a simple conservative approximation is going to have to assume a lot of cache misses, branch misses causing pipeline stalls and so on, which is going to mean the WCET is only a tiny fraction of actual performance.
Solution 3:[3]
The hard real-time performance really depends on the application and circumstancens. But it's quite a struggle
You need very detailed knowledge about:
- CPU
- memory management
- compilers
- your mainboard with it's peripherals
- OS
Check here for some ideas: https://rt.wiki.kernel.org/index.php/HOWTO:_Build_an_RT-application
Next is your time constrains. Is it microseconds, milliseconds or hundreds of milliseconds? And how hard are your real-time requirements really? Because in a closed loop control you can skip one or two cycles as long as 99.9% of the time you meet the deadline line.
Robotic companies like Kuka are doing it or at least have done it in the past.
In general:
For microseconds precsions: Get a counsulting contract with Intel and hire someone who has done this before.
For milliseconds precsions: Get a counsulting contract with someone who has done this before.
And prepare for unforseen issues, because you surely will missed one of the many details!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Filippo Savi |
| Solution 2 | Paul Johnson |
| Solution 3 | BREMI |
