Results 1 to 6 of 6
Run a multi-thread program in 2.4 kernal, I can see each thread has its own PID in top command, while in 2.6 kernal, it seems all threads share a unique ...
- 09-03-2009 #1Just Joined!
- Join Date
- Aug 2009
- Posts
- 10
Thread ID in Linux
Run a multi-thread program in 2.4 kernal, I can see each thread has its own PID in top command, while in 2.6 kernal, it seems all threads share a unique ID, since in top command, I can see only one PID for my program.
Is this correct?
- 09-04-2009 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
The 2.6 kernel has integrated threading much more thoroughly than 2.4 and earlier kernels. Yes, it is correct in that a thread id is not a process id in 2.6, even though each thread can be scheduled separately, allowing each thread to run on a different CPU/core.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 09-04-2009 #3Just Joined!
- Join Date
- Aug 2009
- Posts
- 10
Thanks for your reply.
In Top command window, I can only get the single PID for all threads, is there any tool I can check thread ID for each thread?
- 09-04-2009 #4Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
You can get thread info from the ps command with the -L option. See the ps man pages for more information. Also, you can get thread info from top with the 'H' toggle.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 09-06-2009 #5Just Joined!
- Join Date
- Jul 2009
- Posts
- 10
You can associate thread id with master pid using pstree -p. It's useful for visual display.
- 09-07-2009 #6Just Joined!
- Join Date
- Aug 2009
- Posts
- 10
Is there any way I can print out the current process/thread info on each cpu in my own program?
I guess there may be some function calls I can use in Linux, but I am not sure.


Reply With Quote