Posix shared memory vs mapped files

后端 未结 3 1272
情话喂你
情话喂你 2021-01-31 04:11

Having learnt a bit about the subject, can anyone tell, what is the real difference between POSIX shared memory (shm_open) and POSIX mapped files (mmap)?

Both seems to u

3条回答
  •  你的背包
    2021-01-31 04:32

    Basically shared memory is an form of IPC.The shared region is created in /dev/shm which is created in memory only(RAM) and it requires no disk operations, hence it is a faster method of IPC.Although IPC can be done using disk file and then using mmap too, but it would be comparetively slow.Alternatively you can always use MAP_ANONYMOUS with mmap which does not back up with any disk file.

提交回复
热议问题