difference between message queue and shared memory?

后端 未结 4 1318
挽巷
挽巷 2021-02-01 08:30

I read a lot of articles about differences between message queue and shared memory. But still not clear which one is good for achieving good performance.

Like shared mem

4条回答
  •  闹比i
    闹比i (楼主)
    2021-02-01 09:29

    Message Queue and shared memory are used to share data between 2 processes. Message queue requires data to be shared in specific format. Both processes must agree on this and share the messages. Kernel allows us to read entire message or read nothing for message queues. But shared memory requires part of segment is shared between 2 processes, both can do some synchronization technique and share the data between processes. Since there is no need to copy data to share to other process, shared memory is faster.

提交回复
热议问题