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.
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.
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).
My understanding is that that shared memory is built on top of mapped files, but This Page seems to indicate that the ability to use memory mapped files as shared memory is conditional.