Comparing Unix/Linux IPC

前端 未结 4 1131
情书的邮戳
情书的邮戳 2020-11-28 00:33

Lots of IPCs are offered by Unix/Linux: pipes, sockets, shared memory, dbus, message-queues...

What are the most suitable applications for each, and how do they perf

4条回答
  •  渐次进展
    2020-11-28 00:58

    It's worth noting that lots of libraries implement one type of thing on top of another.

    Shared memory doesn't need to use the horrible sysv shared memory functions - it's much more elegant to use mmap() (mmap a file in on a tmpfs /dev/shm if you want it named; mmap /dev/zero if you want forked not exec'd processes to inherit it anonymously). Having said that, it still leaves your processes with some need for synchronisation to avoid problems - typically by using some of the other IPC mechanisms to do synchronisation of access to a shared memory area.

提交回复
热议问题