Shared Memory when it's for read only

2019-07-30 19:17发布

问题:

I am reading beej's guide for Shared Memory Segments

At the end he says:

More commonly, a process will attach to the segment and run for a bit while other programs are changing and reading the shared segment. It's neat to watch one process update the segment and see the changes appear to other processes. Again, for simplicity, the sample code doesn't do that, but you can see how the data is shared between independent processes.

My question is: it is necessary when the shared memory is for read only?

回答1:

The main purpose of shared memory is the Inter-process communication (IPC). But when you make shared memory read only the purpose is defeated.So at least there should be one process which can write into it and then you can make to READ ONLY for rest of the processes.