Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding usage of resources (CPU and memory) by threads of a process in unix (solaris/linux)

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.

like image 491
mkamthan Avatar asked Dec 02 '25 19:12

mkamthan


1 Answers

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))

like image 82
Arnaud Avatar answered Dec 04 '25 07:12

Arnaud



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!