Find the answer to your Linux question:
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 ...
  1. #1
    Just 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?

  2. #2
    Linux Guru Rubberman's Avatar
    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!

  3. #3
    Just 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?

  4. #4
    Linux Guru Rubberman's Avatar
    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!

  5. #5
    Just Joined!
    Join Date
    Jul 2009
    Posts
    10
    You can associate thread id with master pid using pstree -p. It's useful for visual display.

  6. #6
    Just 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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...