LWN.net Logo

struct pid, struct pid, struct pid

struct pid, struct pid, struct pid

Posted Nov 4, 2007 3:44 UTC (Sun) by ebiederm (subscriber, #35028)
Parent article: Notes from a container

If you need to store a persistent reference to a user space process use a 
struct pid *.  Not a task_struct reference.

References can potentially last for a long time after user space processes 
have exited so holding a reference to a tiny struct pid is much cheaper 
memory wise.  In addition a struct pid is a drop in replacement for a 
pid_t (except for the need for reference counting).  A struct pid can 
reference process groups, thread groups, and sessions not just individual 
processes.  Further a struct pid is immune from pid wrap around, removing 
a whole class of theoretical problems from being issues in the kernel.



(Log in to post comments)

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds