I have a multi-threaded application(C++ and pthread library) and I will like to know how much resources(CPU and memory) each thread uses. Is there a way to find out these details on Solaris and Linux both or on either of them.
- For linux there's an exact duplicate(stackoverflow.com/questions/1431569/…).P Shved– P Shved2009-10-05 10:23:59 +00:00Commented Oct 5, 2009 at 10:23
- I checked this out beforehand. My question was also for Solaris. Have not found any thing yet. Only thing i can conclude now is that talking about memory consumption per thread is not a good idea as they share the same memory space. May be we can only calculate what memory was allocated or deallocated by a thread (How to do this ??).mkamthan– mkamthan2009-10-06 06:19:16 +00:00Commented Oct 6, 2009 at 6:19
Add a comment |
1 Answer
You could use the ps command with some option:
ps -eLo pid,ppid,lwp,nlwp,osz,rss,ruser,pcpu,stime,etime,args | more PID PPID LWP NLWP SZ RSS RUSER %CPU STIME ELAPSED COMMAND 0 0 1 1 0 0 root 0.0 Oct_02 4-02:13:37 sched 1 0 1 1 298 528 root 0.0 Oct_02 4-02:13:36 /sbin/init 2 0 1 1 0 0 root 0.0 Oct_02 4-02:13:36 pageout
Have a look at the ps man's page to get some information (LWP (light weight process))
3 Comments
mkamthan
Is LWP a thread? I mean in Linux/Solaris terms. Since in what you have pasted here PPID is 0, I suppose that its a process and not a thread. Am I correct?
brianegge
Yes. LWP is a thread. theeggeadventure.com/wikimedia/index.php/…
jasonk
As far as i can tell - the pcpu flag gives CPU usage for the process, not for the LWP.