刷新共享内存中的问题

时间:2016-04-12 20:14:53

标签: c ipc

假设父进程分叉子进程并且他们将通过共享内存(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;

如果需要冲洗,那么解决方案是什么样的?

0 个答案:

没有答案