如何写入时复制工作叉EXEC? [英] How does copy-on-write work in fork-exec?
问题描述
一个过程叉
是个子进程,并调用执行exec()
中的子进程。
与写入时复制后,叉
父进程和子进程共享的内存。
当子进程调用执行exec()
加载另一个进程,将Linux的母体存储复制到新的内存和孩子也加载另一个进程这一新的内存?如果是这样,这是否意味着用做叉Exec时写入时复制没有得到数据分叉过程?
通过写入时复制后,
叉
父进程和子进程共享的内存。
块引用>是阅读,也没有进行写入。对于派生的子进程会创建一个新的地址空间,不仅是填充它,直到把它写在孩子发生。
如果
叉()
后面紧跟着执行exec()
,为孩子创造的地址空间,而叉()
ING通常不使用,但是由一个新的,即该过程的exec()$ C $创建的替换C>编辑。
A process
fork
s a child process, and callsexec()
in the child process. With copy-on-write, afterfork
the parent process and child process share the memory.When the child process calls
exec()
to load another process, will Linux copy the parent memory to the new memory and the child loads another process also to this new memory? If so, does that mean the process forked with copy-on-write got no data when doing fork-exec?解决方案With copy-on-write, after
fork
the parent process and child process share the memory.Yes for reading and no for writing. A new address space is created for the forked child process, only it is not populated until a write to it occurs by the child.
If
fork()
is immediately followed byexec()
, the address space created for the child whilefork()
ing typically isn't used but is replaced by a new one, namely the one created for the processexec ()
ed.这篇关于如何写入时复制工作叉EXEC?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!