Performance difference between IPC shared memory and threads memory

后端 未结 5 1704
孤独总比滥情好
孤独总比滥情好 2020-12-08 04:54

I hear frequently that accessing a shared memory segment between processes has no performance penalty compared to accessing process memory between threads. In other words, a

5条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-08 05:54

    The cost of shared memory is proportional to the number of "meta" changes to it: allocation, deallocation, process exit, ...

    The number of memory accesses does not play a role. An access to a shared segment is as fast as an access anywhere else.

    The CPU performs the page table mapping. Physically, the CPU does not know that the mapping is shared.

    If you follow the best-practice (which is to rarely change the mapping) you get basically the same performance as with process-private memory.

提交回复
热议问题