Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 2: Process Management and Scheduling


<pid.h>
enum pid_type
{
PIDTYPE_PID,
PIDTYPE_PGID,
PIDTYPE_SID,
PIDTYPE_MAX
};

level 0

level 1

level 2

1 PID_TYPE_PID
2 PID_TYPE_PGID
3

3

2

1
PID_TYPE_SID tasks

struct task_struct

task_struct task_struct

struct pid

pids [1]

pid

pid

pid

mode

mode

mode

pid

mode
pid

mode

pids [2]

pids [3]

parent

PID namespace

pid_ hask struct upid

numbers[level]
struct upid

Hashed by pid and namespace

level n +1 entries

struct pid_namespace

Figure 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.

Free download pdf