I've patched my Raspbian OS with the PREEMPT_RT patch to make my OS preemptable. How do I make one of my applications run real-time? (Loadable Kernel Modules, etc.)
-
There might be some helpful info over at [Raspberry Pi Stack Exchange](https://raspberrypi.stackexchange.com/help/on-topic) such as this: [Is it possible to run real time software?](https://raspberrypi.stackexchange.com/q/1408). – Gino Mempin Aug 09 '19 at 00:15
-
Possible duplicate of https://stackoverflow.com/questions/35766811/build-an-rt-application-using-preempt-rt – Clifford Aug 09 '19 at 22:48
-
Reconsider your tags. Why are Python or C relevant for example? – Clifford Aug 09 '19 at 23:33
1 Answers
Processes in Linux are already preemptable through round-robing time-slicing. What the PREEMPT_RT patch does is support priority based preemption. That is the highest priority ready thread runs until it blocks or is preempted by a higher priority thread becoming ready. Without PREEMPT_RT higher priority threads simply get allocated more and/or larger time slices. (Somewhat simplistic description - Linux scheduling is a little more sophisticated that that in practice).
A process does not magically become "real-time" by being run on a real-time OS or even PREEMPT_RT. These simply provide real-time support - your application still has to be designed appropriately to meet real-time deadlines. From Real-time Linux Wiki FAQ:
A bad designed application on non-RT will never behave realtime on RT.
You can set the priority and scheduling policy of a existing process using chrt. But as explained, running a process at a high priority does not necessarily make it "real-time". The worst case will be that your process hogs the processor so that nothing else can run.

- 88,407
- 13
- 85
- 165