From mboxrd@z Thu Jan 1 00:00:00 1970 From: dhylands@gmail.com (Dave Hylands) Date: Fri, 10 Feb 2012 21:12:02 -0800 Subject: How to find the child processes? In-Reply-To: <04928acc-76be-4785-99ea-d7ecab63f0a8@mail5.gatech.edu> References: <6089e33a-29ad-4df9-aac8-006e9b42fbfa@mail5.gatech.edu> <04928acc-76be-4785-99ea-d7ecab63f0a8@mail5.gatech.edu> Message-ID: To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org Hi Suren, On Fri, Feb 10, 2012 at 7:45 PM, Surenkumar Nihalani wrote: > Hi guys, > > I need help, again. I am writing a kernel module. I have the pid and tid > from the current structure. How do I figure our the number of threads in the > given process id? > If possible, how do I get the individual tids within the pid? So I took a look at how /proc/TTT/task was implemented, and basically it uses next_thread from sched.h, which follows the thread_group structure stored inside task_struct. You need to acquire the appropriate locks and do checks to make sure that the thread hasn't died on you, but that's the jist of it. -- Dave Hylands Shuswap, BC, Canada http://www.davehylands.com