Search code examples
clinuxprocesslinux-kernel

Efficient way to find task_struct by pid


Is there an efficient way of finding the task_struct for a specified PID, without iterating through the task_struct list?


Solution

  • What's wrong with using one of the following?

    extern struct task_struct *find_task_by_vpid(pid_t nr);
    extern struct task_struct *find_task_by_pid_ns(pid_t nr,
                struct pid_namespace *ns);