Creating Processes
Unix operating systems rely heavily on process creation to satisfy user requests. For example, the shell creates a new process that executes another copy of the shell whenever the user enters a command.
Traditional Unix systems treat all processes in the same way:
resources owned by the parent process are duplicated in the child
process. This approach makes process creation very slow and inefficient,
because it requires copying the entire address space of the parent
process. The child process rarely needs to read or modify all the
resources inherited from the parent; in many cases, it issues an
immediate execve( )
and wipes out the
address space that was so carefully copied.
Modern Unix kernels solve this problem by introducing three different mechanisms:
The Copy On Write technique allows both the parent and the child to read the same physical pages. Whenever either one tries to write on a physical page, the kernel copies its contents into a new physical page that is assigned to the writing process. The implementation of this technique in Linux is fully explained in Chapter 9.
Lightweight processes allow both the parent and the child to share many per-process kernel data structures, such as the paging tables (and therefore the entire User Mode address space), the open file tables, and the signal dispositions.
The
vfork( )
system call creates a process that shares the memory address space of its parent. To prevent the parent from overwriting data needed by the child, ...
Get Understanding the Linux Kernel, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.