Posix shared memory vs mapped files

后端 未结 3 1217
情话喂你
情话喂你 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:55

    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.

    The use of the mmap() function is restricted by the QSHRMEMCTL System Value. When this system value is 0, the mmap() function may not create a shared mapping having with PROT_WRITE capability. Essentially, this prevents the creation of a memory map that could alter the contents of the stream file being mapped. If the flags parameter indicated MAP_SHARED, the prot parameter specifies PROT_WRITE and the QSHRMEMCTL system value is 0, then the mmap() functions will fail and an error number of EACCES results.

提交回复
热议问题