Chapter 2: Process Management and Scheduling
struct list_head sibling; /* linkage in my parent’s children list */
...
}
❑ childrenis the list head for the list of all child elements of the process.
❑ siblingsis used to link siblings with each other.
Parent prcess
Child prcess
Children
sibling sibling sibling
Figure 2-6: Family relationships between processes.
New children are placed at thestartof thesiblingslist, meaning that the chronological sequence of
forks can be reconstructed.^7
2.4 Process Management System Calls
In this section, I discuss the implementation of theforkandexecsystem call families. Normally, these
calls are not issued directly by applications but are invoked via an intermediate layer — the C standard
library — that is responsible for communication with the kernel.
The methods used to switch from user mode to kernel mode differ from architecture to architecture.
In Appendix A, I describe at length the mechanisms used to switch between these two modes and also
explain how parameters are exchanged between userspace and kernel space. For the time being, it is
sufficient to regard the kernel as a ‘‘program library‘‘ used by the C standard library as mentioned briefly
in Chapter 1.
2.4.1 Process Duplication
The traditionalUnixsystem call to duplicate a process isfork. However, it is not the only call imple-
mented by Linux for this purpose — in fact, there are three:
(^7) Kernel versions before 2.6.21 had three helper functions:younger_sibling,older_sibling,andeldest_child,which
gave some aid in accessing the described lists and their elements. They were used to produce debugging output, which had, how-
ever, not proved very useful, so it was removed. Patch author Ingo Molnar noticed that the corresponding code was among the
oldest elements of the kernel and noted this accordingly. This led another well-known developer to sign off the patch asLinus
’snif’ Torvalds...