如果已经分配了一些内存(例如使用malloc
),是否有可能将该内存与另一个进程共享,例如将页面标记为共享?
要清楚的是,这与将内存初始分配为共享内存不同,例如使用shmget
等。 显然这是可以做到这一点与memcpy
,但有没有办法直接做到这一点?
mmap() creates a new mapping in the virtual address space of the calling process. The starting address for the new mapping is specified in addr. The length argument specifies the length of the mapping.
所以我想象: