top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How the Kernel handles the copy on write bit of a page, when the bit is set?

+3 votes
276 views
How the Kernel handles the copy on write bit of a page, when the bit is set?
posted Jan 4, 2016 by Mohammed Hussain

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

In situations like, where the copy on write bit of a page is set and that page is shared by more than one process, the Kernel allocates new page and copies the content to the new page and the other processes retain their references to the old page. After copying the Kernel updates the page table entry with the new page number. Then Kernel decrements the reference count of the old pfdata table entry.
In cases like, where the copy on write bit is set and no processes are sharing the page, the Kernel allows the physical page to be reused by the processes. By doing so, it clears the copy on write bit and disassociates the page from its disk copy (if one exists), because other process may share the disk copy. Then it removes the pfdata table entry from the page-queue as the new copy of the virtual page is not on the swap device. It decrements the swap-use count for the page and if count drops to 0, frees the swap space.

answer Jan 5, 2016 by Manikandan J
Similar Questions
+1 vote

In the early versions of Unix system implementation, when a process called the fork() system call. It creates a child process, which is a copy of the parent process and has the copy of parent data space, heap and stack in the separate memory and there is no sharing except the code or text segment between the child and parent process.

But in current implementations, when fork() system called by a process; it does not performs the complete copy of data space, heap and stack. Instead, a technique called copy-on-write is used. In which both parent and child share these same region but the protection have changed read only by the kernel. when child tries to write, a page fault error is generated (does not show in the user space). which is handled by the kernel and a copy of page copied into the child process address space by the kernel and marked as writable.

Now my doubt is, when a child process called fork() system call and grand children try to write or modify, how will it work??

+2 votes

How a background process is treated by operating system ?

...