How exactly does copy on write work

前端 未结 2 1743
南旧
南旧 2021-01-14 15:39

Say we have a certain parent process with some arbitrary amount of data stored in memory and we use fork to spawn a child process. I understand that in order for the OS to p

2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-14 16:15

    Some UNIX implementations share the program text between the two since that cannot be modified. Alternatively, the child may share all of the parent’s memory, but in that case the memory is shared copy-on-write, which means that whenever either of the two wants to modify part of the memory, that chunk of memory is explicitly copied first to make sure the modification occurs in a private memory area.

    Excerpted from: Modern Operating Systems (4th Edition), Tanenbaum

提交回复
热议问题