我有两个进程A和B.A和B有时需要进行通信(双向)以传递信号,消息等.
我已经做了一些关于IPC在 Linux中可用的基础研究,如信号量,消息队列,dbus等.
现在我在决定使用哪一个时感到困惑,谁能告诉我哪个IPC更适合我的应用?
我已经做了一些关于IPC在 Linux中可用的基础研究,如信号量,消息队列,dbus等.
现在我在决定使用哪一个时感到困惑,谁能告诉我哪个IPC更适合我的应用?
提前致谢
编辑:阐述应用程序. (这是一个嵌入式应用程序)
过程A将监控温度,速度计算等.过程B将驱动电机,读取传感器值(数值)等.有时我需要将信号发送到过程B,告知达到最高温度,因此停止驱动电机.有时需要将从流程A中的传感器读取的数据发送到流程B.像这样,需要跨流程传递数字数据.我在ARM架构中这样做.
解决方法
IPC技术的选择取决于您尝试实施的应用.以下是对性能的良好比较:
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
这是一个更好的比较