LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   What is tgid , tracerpid of a process (https://www.linuxquestions.org/questions/linux-software-2/what-is-tgid-tracerpid-of-a-process-756094/)

iamjayanth 09-17-2009 11:46 PM

What is tgid , tracerpid of a process
 
Hi all,

I am trying to learn the contents of some of the procfiles. In
/proc/pid/status there are two entries tgid and tracerpid. What these ids mean ?

neonsignal 09-18-2009 01:58 AM

tgid is the thread group id (ie, the process id), which for a single threaded process will actually be the process id.

tracerpid is the process id of the application that is tracing this process (typically 0, when it is not being traced).

Documentation can be found by doing 'man proc'.

iamjayanth 09-19-2009 02:34 AM

Thanks neonsignal for the reply...But the tgid part is very confusing....

Is the tgid part is a thread specification or a process specification....

Now please correct me if and where I am wrong..I have conceived this much...


-> A thread group contain all threads inside a single process...


-> Since in GNU/Linux thread implementation , kernel (atleast scheduler) considers all thread in a single process as different processes that happen to share same memory address space...So multithreaded process has more than one process id , one for each thread...


-> So the thread id of each thread is different and thread group id is the pid which scheduler gave specifically (temporarily ) for that thread..

Quote:

which for a single threaded process will actually be the process id.

-> That means a multi threaded process has more than one tgid ?



Can you please help me...

neonsignal 09-19-2009 05:25 AM

Let me define a thread as a virtual CPU, a process as a virtual CPU plus the state context (eg address space).

The ids are used for both process and thread identification. Because of the way the older LinuxThreads implemented threads, each thread was given a different process id (not Posix compliant). In the newer NPTL pthreads, the threads share a process id but have different thread ids.

The naming in the status file is confusing, because the Tgid identifies the process (so-called 'thread group'). And the Pid is the thread id! (remembering that the thread id of the first thread is also used as the process id).

So yes, in the NPTL scheme, the thread group provides access to the context for all the threads within a single process. A multi-threaded process has only one Tgid (and only one parent id).

The older LinuxThreads is messier (they have a manager thread which is the parent of non-main threads).

iamjayanth 09-19-2009 06:06 AM

Thanks neonsignal...I got confused with thread old implementation since I only knows that one...Thank you very much


All times are GMT -5. The time now is 12:58 AM.