Perhaps these links may help:
After going through the second link, it becomes clear that namespaces are a great way to isolate resources. And in any OS, including Linux, processes are one of the most important resources. In your own words
, , PID "1" . "chroot" . , 4- ...
, , / . , PID , "". , , root. , , .
, , . , , .
LWN article PID. :
PID, , struct pid. , , ID, node, - . . PID: (PID), (PGID) (SID). PGID SID , , , , . PID . , PID , . PID 1024 256 . , struct pid . struct pid PID:
struct pid {
atomic_t count;
int nr;
struct hlist_node pid_chain;
struct hlist_head tasks[PIDTYPE_MAX];
struct rcu_head rcu;
};
:
struct upid {
int nr;
struct pid_namespace *ns;
struct hlist_node pid_chain;
};
struct pid {
atomic_t count;
struct hlist_head tasks[PIDTYPE_MAX];
struct rcu_head rcu;
int level;
struct upid numbers[0];
};
, struct upid PID - PID. struct pid PID , , task_pid_nr(), pid_nr_ns(), find_task_by_vpid() ..
, , . , . struct nsproxy. , . PID, . PID task_active_pid_ns.
struct task_struct - , nsproxy, struct nsproxy. , , task_struct, struct nsproxy struct pid.
Linux , execve ( exec). , do_fork copy_process.
:
task_struct dup_task_struct.copy_namespaces. nsproxy , nsproxy .INIT ( PID, , ), PID alloc_pid, PID fork ed . :
nr = alloc_pidmap(tmp);
if(nr<0)
goto out_free;
pid->numbers[i].nr = nr;
pid->numbers[i].ns = tmp;
upid, PID, , .
, copy process, PID task_struct pid_nr, ( PID nr, INIT) PID task_struct.
copy_process task_struct PID pid_link task_struct attach_pid.
Theres , , .
. ( ) , : 3.17.2.