Chapter 2: Process Management and Scheduling
<pid.h>
enum pid_type
{
PIDTYPE_PID,
PIDTYPE_PGID,
PIDTYPE_SID,
PIDTYPE_MAX
};level 0level 1level 21 PID_TYPE_PID
2 PID_TYPE_PGID
3321
PID_TYPE_SID tasksstruct task_structtask_struct task_structstruct pidpids [1]pidpidpidmodemodemodepidmode
pidmodepids [2]pids [3]parentPID namespacepid_ hask struct upidnumbers[level]
struct upidHashed by pid and namespacelevel n +1 entriesstruct pid_namespaceFigure 2-5: Overview of data structures used to implement a namespace-aware representation of IDs.Notice that thread group IDs arenotcontained in this collection! This is because the thread group ID is
simply given by the PID of the thread group leader, so a separate entry is not necessary.
A process can be visible in multiple namespaces, and the local ID in each namespace will be different.
leveldenotes in how many namespaces the process is visible (in other words, this is the depth of the
containing namespace in the namespace hierarchy), andnumberscontains an instance ofupidfor each
level. Note that the array consists formally of one element, and this is true if a process is contained only
in the global namespace. Since the element is at the end of the structure, additional entries can be added
to the array by simply allocating more space.