假设父进程分叉子进程并且他们将通过共享内存(shm_open
)共享数据块,我们是否必须考虑数据刷新,以便每次子进程修改共享内存时父进程可以马上知道吗?
/* Parent */
int fd = shm_open(...)
void seg = mmap(...)
... // clear all data in seg
while(seg->data == true) {
// flush here so that the parent won't keep reading data from register?
}
/* Child*/
int fd
int fd = shm_open(...)
void seg = mmap(...)
seg->data = true;
如果需要冲洗,那么解决方案是什么样的?