Politechniczny
Politechniczny

Reputation: 503

How to communicate between processes in realtime Linux?

There are a lot of examples how to write realtime code for RT-Linux by FSMLabs but this distro has been abandoned many years ago. Currently PREEMPT_RT patch for vanilla kernel is actively developed but there are only few code examples on official Wiki. First let me introduce my issue.

I'm writing a project containing 2 programs:

  1. Virtual machine of byte code - it must work as realtime application - it has 64 KB of I/O memory and 64 KB for byte code.
  2. Client program - it will read and write I/O memory, start/pause machine, load new programs, set parameters, etc. It doesn't have to be realtime.

How to communicate between these processes to keep process (1) realtime and avoid page faults or other behaviors that can interfere realtime app?

Approach 1. Use only threads

There are 2 threads:

Approach 2. Shared memory

In old FSMLabs it's recommended to use shared global memory between processes. Modern PREEMPT_RT's Wiki page recommends using mmap() for process data sharing but in the same article it discourages mmap() because of page faults.

Approach 3. Named pipes

It's more flexible way to communicate between processes. However, I'm new to programming in Linux. We want to share memory between machine and client but it should also provide a way to load new program (file path or program code), stop/start machine, etc. Old FSMLabs RT-Linux implemented its own FIFO queues (named pipes). Modern PREEMPT_RT doesn't. Can using names pipes break realtime behavior? How to do it properly? Should I read data with O_NONBLOCK flag or create another thread for reading/writing data from/to pipe?

Do you know other ways to communicate between processes where one process must be realtime? Maybe I need only threads. However, consider a scenario that more clients are connected to virtual machine process.

Upvotes: 4

Views: 1550

Answers (1)

Xter
Xter

Reputation: 73

For exchanging data between processes executing on the same host operating system you can also use UNIX domain sockets.

Upvotes: 1

Related Questions