开发者

sharing address space versus duplicating the page table entries

  1. Before copy on write (COW), when it says that the parent and child process share the same address space, it means that they share the same code segment, data segment, heap and stack right?

  2. If the parent and child process share the same address space before COW, what does the page table entries are copied from parent process to child process mean?

  3. Does duplicating the page table entries mean duplicating the address space?

    开发者_开发问答


lets say your process is got var name X that have a virtual address 100 and physical address 200. the PTE is holding a mapping of addresses from virtual 100 to physical 200.

after the fork, each process (parent and child) will have his private PTE. at this point both PTEs will map virtual 100 to physical 200.

as long as both process just read from there they both will read from physical address 200.

when the first one will try to write there, the data from physical address will be copy to a new physical space, lets say 300, and his (and only his) PTE will be update so virtual 100 will be mapped to physical 300. that way it's transparent to the process because he is still using the same (virtual) address.

*Note: this is just an abstract, and the real thing is happening in page resolution.


  1. Yes, the same physical memory is shared by the processes (parent and child).

  2. It means that each have his own PTE that translate the virtual address space to the physical address space. right after the fork they are the same in general.

  3. Yes, it mean after the fork each have his own address space which are identical at the beginning but can and will be changed later. for example on COW, malloc, free, basically for any change of the memory usage of the processes.


The page tables are a per-process data structure that map between linear addresses and physical addresses. The page table entries are copied from the parent to the child, which means that immediately after the fork(), both processes are using identical page tables, which map the same physical addresses to the same linear addresses in each processes address space. After this, though, the page tables start to diverge as each COW fault occurs and other address space changes are made.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜