Is there an efficient way of finding the task_struct
for a specified PID, without iterating through the task_struct
list?
* A struct pid is the kernel's internal notion of a process identifier. * It refers to individual tasks, process groups, and sessions. While. * there are processes attached to it the struct pid lives in a hash. * table, so it and then the processes that it refers to can be found.
The task_struct is a relatively large data structure, at around 1.7 kilobytes on a 32-bit machine. This size, however, is quite small considering that the structure contains all the information that the kernel has and needs about a process.
From the perspective of Virtual memory system, task_struct is allocated by the Slab allocator, so that it's located in the kernel space.
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With