user4260053
user4260053

Reputation:

what is meaning of copy on write in linux during fork?

During fork a process acquires its page tables from its parent with the entries marked as read-only (shared with parent). Then, if the child process tries to write to that memory, it create new page and mark as wtire. My question is if parent process want to wtire on that page, will it create new page? if yes then there will be 3 pages (page for child with write permission+page for parent with write permission+ one shared pages)in physical memory?

please explain anybody

Upvotes: 0

Views: 225

Answers (1)

ChiefTwoPencils
ChiefTwoPencils

Reputation: 13940

To clarify, there's the processes' page table and processes' page frames. The page tables in each "point" to the same frame. So...

Actually, the kernel traps attempts by either the parent or child process to modify one of the pages. If either do, the kernel makes a duplicate of the page about to be modified. After that they each modify their private copies without the other seeing it; there are two frames now. So, no; there won't be three pages.

Upvotes: 1

Related Questions