Reputation: 7434
I am sharing some memory (created with shm_open
where I map different "regions" with mmap
) across multiple processes. I am using named semaphores to synchronize accesses to that memory.
I have a region in that memory that is read-only (it has been set by the process that creates the shared memory object). Do I still need to use mutexes to let the processes read that region? If that region can be read concurrently I can drop named semaphores and share unnamed semaphores instead.
The question is similar to what asked here but maybe the OP was not clear enough.
Upvotes: 1
Views: 2496
Reputation: 7434
According to multiple sources, reading the same memory seems to not introduce race conditions, so it could be done without locking. I have a couple of systems running from months with one process writing (with a global lock) and two other processes continuosly reading the same shared memory and I have never had issues.
Upvotes: 1