Im trying to understand better how the kernel implement pid namespace .
One of the basic structure that is being used is struct pid
:
struct pid {
atomic_t count;
unsigned int level;
/* lists of tasks that use this pid */
struct hlist_head tasks[PIDTYPE_MAX];
struct rcu_head rcu;
struct upid numbers[1]; }
Now from what I understand numbers array keeps track of the process different pids in different pid namespaces.
What I dont understand is the purpose of tasks
member.
It says here: (LWN) :
.." This structure contains the ID value, the list of tasks having this ID.."
So I understand from this that the same pid is shared between couple of proccess/tasks . Now, different proccess/threads can share same tpid/gpid but not the same pid! So how come there are list of tasks having the same PID? What am I missing?
Thanks
pid.tasks[PIDTYPE_PID]
. Tasks do not share the PID but they can sharePGID
andSID
. They are all on the same array for uniformity and code sharing. – Karim Manaouil