How to do real time?

Topics about the Software of Revolution Pi
Post Reply
mknopf
Posts: 3
Joined: 14 Jul 2022, 15:46
Answers: 0

How to do real time?

Post by mknopf »

Hello all.

Can someone explain to me how I can create a real-time programme? What requirements do I have to fulfil? How do you create a real-time programme? Where can I find more information?

Regards
mknopf
User avatar
nicolaiB
KUNBUS
Posts: 869
Joined: 21 Jun 2018, 10:33
Answers: 7
Location: Berlin
Contact:

Re: How to do real time?

Post by nicolaiB »

It highly depends on your definition of real-time. Even real-time has a cycle time, which the scheduler tries to ensure. Generally speaking you can run any application with real-time priorities, by prefixing the call with chrt (or set ilthe Prio directly in your code). Keep in mind that lots of stuff can and will break your rt cycle time if not done right (blocking stuff like io access etc).

Nicolai
User avatar
p.rosenberger
KUNBUS
Posts: 89
Joined: 03 Jul 2020, 11:07
Answers: 1

Re: How to do real time?

Post by p.rosenberger »

Hi mknopf,

real time programming is nothing you can learn from a post in a forum. There are many things you are not allowed to do in your real time application. And it starts with you need to ensure that your program doesn't need to load pages from the storage. So all parts of your real time application needs to stay in memory (https://linux.die.net/man/2/mlockall) Then you need to make sure you never block on for example I/O. So you can't write any files or to any I/O from your real time thread/process. And many things more.

Realtime development has nothing to do with cyclic programming. An SPS uses a cycle which is deterministic and thus you can implement realtime use cases with it. Realtime only says an event can be handled in a defined time.

There are some limiting conditions on the RevPi. We use kernel threads with realtime priorities to implement the communication with the extension modules. Also some other driver use realtime priorities. Also the communticaton with the extension modules is done in a cyclic manner. Which leaves you with a delay from the point when an event occurred (on the extension modules) a until you can process this event.

I hope this rather shallow overview helped you.

Best regards,
Philipp
Post Reply