Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux IPC selection?

I have two processes A and B. A and B needs to communicate (Bi-directional) sometimes for passing signals, messages etc.
I have done some basic research about IPC's available in Linux like semaphore, message queues, dbus etc.
Now I am in confusion in deciding which one to use, Can anyone tell me which IPC is better to use for my application ?

Thanks in advance

Edited: Elaborating the Application. ( It is an Embedded Application )
Process A will be monitoring Temperature, speed calculation etc. Process B will be driving the motor, reading the sensor values (Numeric) etc. Sometimes I need to send the signal to process B telling Max temperature is reached, so stop driving motor. Sometimes needs to send the data read from sensor in Process A to Process B. Like this the Numeric data needs to be passed across process. And I am doing this in ARM Architecture.

like image 399
duslabo Avatar asked Feb 20 '13 17:02

duslabo


1 Answers

Selection of IPC technique depends on application which you are trying to implement. Below is a good comparison base on performance:

IPC name      Latency     Throughput   Description
-----------------------------------------------------------------------------------------
Signal        Low          n/a         Can be used only for notification, traditionally-
                                       to push process to change its state

Socket        Moderate     Moderate    Only one mechanism which works for remote nodes,
                                       not very fast but universal

D-Bus         High         High        A high-level protocol that increases latency and
                                       reduces throughput compared to when using base
                                       sockets, gains in increased ease of use

Shared        n/a          High        Data saved in-between process runs(due to swapping
memory                                 access time) can have non-constant access latency

Mapped files  n/a          High        Data can be saved in-between device boots

Message      Low           Moderate    Data saved in-between process runs. The message
queue                                  size is limited but there is less overhead
                                       to handle messages

Here is one more nice comparison

Comparing Unix/Linux IPC

like image 103
Satish Avatar answered Sep 21 '22 15:09

Satish