Posix shared memory vs mapped files

SyBer picture SyBer · Feb 14, 2010 · Viewed 22.5k times · Source

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 use the /dev/tmpfs subsystem, rather then older IPC mechanism.

So is there any advantage of using mmap file over shared memory?

Thanks.

Answer

ennuikiller picture ennuikiller · Feb 14, 2010

The distinction is not always clear. Shared memory can be implemented via memory mapped files. An excellent write on this can be found here (as applied to C/C++ programming).