Linux内核使用struct pid在内核空间中表示PID .C代码如下.
struct pid
{
atomic_t count;
/* lists of tasks that use this pid */
struct hlist_head tasks[PIDTYPE_MAX];
int level;
struct upid numbers[1];
};
Run Code Online (Sandbox Code Playgroud)
我无法理解为什么成员任务可以代表"任务列表".因为task_struct是任务的内核内部表示,而一个任务只使用一个task_struct.为什么多个任务可以共享一个"struct pid"?