Re: on the concept of COW

Helge Hafting
2004-11-22T07:30:03Z

Jagadeesh Bhaskar P wrote:

>Hi,
>
> When a process forks, every resource of the parent, including the
>virtual memory is copied to the child process. The copying of VM uses
>copy-on-write(COW). I know that COW comes when a write request comes,
>and then the copy is made. Now my query follows:
>
>How will the copy be distributed. Whether giving the child process a new
>copy of VM be permanent or whether they will be merged anywhere? And
>
>
Merging can only happen if the two pages becomes equal
again. That is extremely unlikely, and checking for this
would cost a lot more than the memory saved.

>shouldn't the operations/updations by one process be visible to the
>other which inherited the copy of the same VM?
>
>
Of course not - the whole reason for copying is so such
modifications won't be visible for the other process.

There may be special cases (shared mapping) where one
process is supposed to see updates done by another - but
then no COW is performed because there is no need.

Helge Hafting