Page 1 of 1

How to do real time?

Posted: 22 Dec 2022, 09:12
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

Re: How to do real time?

Posted: 22 Dec 2022, 09:36
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

Re: How to do real time?

Posted: 18 Jan 2023, 14:18
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