Sharing memory between processes through the use of mmap()

前端 未结 3 2094
遇见更好的自我
遇见更好的自我 2020-12-05 10:43

I\'m in Linux 2.6. I have an environment where 2 processes simulate (using shared memory) the exchange of data through a simple implementation of the message passing mode.

3条回答
  •  渐次进展
    2020-12-05 11:15

    Is it possible to attach that region of memory to the server POST forking, after the client creates it?

    MAP_ANONYMOUS|MAP_SHARED mapped memory can only be accessed by the process which does that mmap() call or its child processes. There is no way for another process to map the same memory because that memory can not be referred to from elsewhere since it is anonymous.

    Using shm_open() call it is possible to create named shared memory which can be referred to and mapped by unrelated processes.

提交回复
热议问题