Process Creation


A new process is created by calling fork(), which creates a child process, and copies all of the parent's contents to it

exec() may be called to replace the contents of the child to a new program

Copy on write

Traditionally, fork() copies all the resources of the parent over to the child. This is inefficient, as data might be shared, or an exec() might be called immediately, wasting the effort of copying.

copy-on-write is thus done, where the actual copying of data to the child is done only when the data is written to. Otherwise, the data is a shared read-only

In this case exec() will never copy the data, since it is not written to, but a new program replaces the contents of the child

The only overhead incurred by fork() is the duplication of the parent's page tables and creation of the PID of the child

results matching ""

    No results matching ""