I have an application that has multiple threads. Every time I start a thread
I write an entry in the log file with the thread id as returned by the
pthread_self () call and a description of what the thread does.
When my application has been running for a while I do a ps -eLf to find out
how much CPU each thread has been using. Unfortunately ps returns LWPs and
pthread_self () returns a thread id.
When I have my application in gdb it shows both the thread id and the LWP
but I can not do this in production.
Does anyone know how in my c++ application I can find out what the LWP is
for a thread so that I can link this information with the output of ps.
Gdb Output:
(gdb) info threads
4 Thread -167969872 (LWP 11083) 0x003d27a2 in _dl_sysinfo_int80 ()
from /lib/ld-linux.so.2
3 Thread -165868624 (LWP 11082) 0x003d27a2 in _dl_sysinfo_int80 ()
from /lib/ld-linux.so.2
2 Thread -162210896 (LWP 11081) 0x003d27a2 in _dl_sysinfo_int80 ()
from /lib/ld-linux.so.2
* 1 Thread -162202816 (LWP 11074) 0x003d27a2 in _dl_sysinfo_int80 ()
from /lib/ld-linux.so.2
ps output:
lx-chdev10.wfg.com:/home/optdev/usa-dev $ ps -eLf|grep PLC
optdev 10906 10855 10906 2 1 19:14 pts/2 00:00:05 gdb --args
../PLCalc -csAppName PLCalc -d 20060605 -csFamily US_OMM
optdev 11074 10906 11074 0 4 19:16 pts/2 00:00:00
/home/optdev/usa-dev.new/linux_bin/pnl/PLCalc -csAppName PLCalc -d
20060605 -csFamily US_OMM
optdev 11074 10906 11081 0 4 19:16 pts/2 00:00:00
/home/optdev/usa-dev.new/linux_bin/pnl/PLCalc -csAppName PLCalc -d
20060605 -csFamily US_OMM
optdev 11074 10906 11082 0 4 19:16 pts/2 00:00:00
/home/optdev/usa-dev.new/linux_bin/pnl/PLCalc -csAppName PLCalc -d
20060605 -csFamily US_OMM
optdev 11074 10906 11083 0 4 19:16 pts/2 00:00:00
/home/optdev/usa-dev.new/linux_bin/pnl/PLCalc -csAppName PLCalc -d
20060605 -csFamily US_OMM