Find the answer to your Linux question:
Results 1 to 7 of 7
Hi, I have an application coded in C++ using Linux. How can i know the number of threads in my application? How can i know how many instances of each ...
  1. #1
    Just Joined!
    Join Date
    Sep 2008
    Posts
    3

    Question How to determine the number of threads?

    Hi,

    I have an application coded in C++ using Linux. How can i know the number of threads in my application? How can i know how many instances of each thread are being created?

    Thanks & Regards,
    Manikanta

  2. #2
    Just Joined! wildpossum's Avatar
    Join Date
    Apr 2008
    Location
    Sydney/Australia
    Posts
    92
    You can run "top" and use the "?" to select the username your process/threadds is running. Top will show you the number and what each thread status is.

    Hope this helps.

  3. #3
    Just Joined!
    Join Date
    Jul 2007
    Posts
    9
    well, since you're using c++, you can easily manage all threads and actually just count them using RAII. Keep in mind C++ doesn't have a standard about threads, so you'll either have to dive into pthreads or "emulate" counting using, like i said, RAII or something ilke that.

  4. #4
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    actually just count them using RAII
    I would have said, "actually just count them using an integer". ;)

    But if you want to go with RAII and that term is unfamiliar to you, go here.
    --
    Bill

    Old age and treachery will overcome youth and skill.

  5. #5
    Just Joined!
    Join Date
    Jul 2007
    Posts
    9
    Quote Originally Posted by wje_lf View Post
    I would have said, "actually just count them using an integer".

    But if you want to go with RAII and that term is unfamiliar to you, go here.
    don't worry, i know what i'm talking about. yes, an integer is needed. but if you put every thread inside a class, and make that class destroy when the thread exits, you can use RAII to easily atomically increase and decrease that integer. sounds like a very good OOP design to me

  6. #6
    Just Joined!
    Join Date
    Sep 2008
    Posts
    3

    Question

    Quote Originally Posted by wje_lf View Post
    I would have said, "actually just count them using an integer".

    But if you want to go with RAII and that term is unfamiliar to you, go here.
    Hi,

    Thanks for the reply.
    I know the threads in my application. I am using pthreads library to create threads. I wanted to know how many instances each thread is creating? Can u help me in this issue.

    Thanks & Regards,
    Manikanta

  7. #7
    Just Joined!
    Join Date
    Sep 2008
    Posts
    3
    Quote Originally Posted by wildpossum View Post
    You can run "top" and use the "?" to select the username your process/threadds is running. Top will show you the number and what each thread status is.

    Hope this helps.
    Hi,

    Thanks for the reply. Can u send me the correct syntax of TOP to be used to find the instances of each thread being created?

    Thanks & Regards,
    Manikanta

Posting Permissions

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