Created
March 17, 2017 09:47
-
-
Save drmalex07/5b72ecb243ea1f5b4fec37a6073d9d23 to your computer and use it in GitHub Desktop.
An example of using shared memory in a POSIX system. #c #linux #shmem #shm_open #shared-memory
shm_unlink
would delete the file under /dev/shm/xxxxx even there are other processes using it ?
@samuel100u
no, it uses a reference-count approach: the OS will delete the region only when all processes have been unlinked. See also the man page
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@DharminB
shm_unlink
would delete the shared memory region from the OS (it appears under /dev/shm); in many cases we want it to remain for other processes to read/write to it.munmap
would destroy (invalidate) the memory mapping for the pointer pointing to the shm region. This affects only the current process and it automatically happens when the process terminates.