Parent Thread Of Child Thread

Parent Thread Of Child Thread

Suppose a process creates some threads say threadC and threadD.
Later on each of these threads create new child threads say threadC1, threadC2, threadC3 etc. So a tree of threads will get created.
Is there any way to find out the parent thread of one such randomly created thread?

Actually when our application starts 70 threads gets created which is as per the requirement.
Later on as per the needs these 70 threads can create more threads.
So apart from these 70 threads a large number of other threads gets created(from these 70 threads) and destroyed randomly.
So imagine there is a tree of threads.
There is an issue coming up in one such randomly created thread.
On debugging the code we saw that the issue will be due to a value set by its
parent thread.
So we have to find the parent thread of this erroneus thread.

We are not able to get the parent thread id of this thread?

Will anybody let us know how to find the parent of such randomly created threads?

Good Evening,

Let's go to the core question as it's near bed time :wink:

From a pure POSIX standpoint, if we want to get the "parent thread id" (the term "parent thread" is BTW is misnomer since POSIX states that all threads are peers), you need to keep track of the "thread's tree" yourself.

Now specifically, if you tell us which OS is (are) targeted, we may perhaps find an OS specific solution.

Cheers, Lo�c

1 Like