Help!

LWP pthread_self ()

 
  

Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Development RSS
Next:  Frage zu Prozessen - /etc/init.d/...  
Author Message
paul
External


Since: Jun 08, 2006
Posts: 1



PostPosted: Thu Jun 08, 2006 9:22 am    Post subject: LWP pthread_self ()
Archived from groups: linux>redhat>devel (more info?)

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
Back to top
dstirk



Joined: Jan 10, 2008
Posts: 1



PostPosted: Thu Jan 10, 2008 11:04 pm    Post subject:

#include <syscall.h>

int tid = syscall(SYS_gettid);
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Development All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum