Serving the Quantitative Finance Community

 
User avatar
JackBryan
Topic Author
Posts: 1
Joined: August 15th, 2010, 6:15 pm

How to monitor each thread behavior of a multithread (pthread) C++ program on Linux ?

January 26th, 2012, 4:26 am

I am running a multithread (pthread) C++ program on Linux (redhat).I want to follow the behavior of the running program but the print-out from threads interleave with each other. It is hard to find out the behavior of each thread.I want to use DDD (a gdb GUI) to analyze the behavior of the program but it needs "motif", when I install "motif", which has an error:cc -c -O -I../../include -I../../imports/x11/include/X11 ./ccimake imake.c imake.c:162:21: error: Xosdefs.h: No such file or directoryI also used helgrind and drd tools but there are a lot of plain text print-out, which makes it confusing the behavior of each thread.Would you please recommend better open-source tools that can help me do debug and analyze/monitor behavior of multiple pthreads clearly and easily ?Is it possible to show each thread in a distinct terminal xterm window w/o mixing up all threads together ?thanks
 
User avatar
Hansi
Posts: 41
Joined: January 25th, 2010, 11:47 am

How to monitor each thread behavior of a multithread (pthread) C++ program on Linux ?

January 26th, 2012, 7:25 am

Which part of the process do you need to check? Performance only or do you need to use something like gdb and inspect elements etc?
 
User avatar
zeta
Posts: 26
Joined: September 27th, 2005, 3:25 pm
Location: Houston, TX
Contact:

How to monitor each thread behavior of a multithread (pthread) C++ program on Linux ?

January 26th, 2012, 12:28 pm

yeh what do you need to know? valgrind{ helgrind,cachegrind,callgrind} is excellent for identifying race conditions, monitoring cache usage and calls executed, respectively. The latter has almost excruciating detail, you may want to use callgrind_annotate to summarise the profile data. There's lots of information available from attaching strace to the pid, and you could always poke through procfs to get context switching data etc etc etc
 
User avatar
JackBryan
Topic Author
Posts: 1
Joined: August 15th, 2010, 6:15 pm

How to monitor each thread behavior of a multithread (pthread) C++ program on Linux ?

January 26th, 2012, 3:40 pm

I want to see what each thread has done during the run-time. Currently, I use printf but all thread print-out are put together and their appearing sequences are interleaved with each other. It is very confusing to follow the print-out at xterm or shell. I need to see:thread 1 has done : .........thread 2 has done : .........clearly and separately.thanks
 
User avatar
zeta
Posts: 26
Joined: September 27th, 2005, 3:25 pm
Location: Houston, TX
Contact:

How to monitor each thread behavior of a multithread (pthread) C++ program on Linux ?

January 26th, 2012, 4:06 pm

pthread_t id = GetCurrentThreadID();
 
 
User avatar
quantmeh
Posts: 0
Joined: April 6th, 2007, 1:39 pm

How to monitor each thread behavior of a multithread (pthread) C++ program on Linux ?

January 26th, 2012, 4:12 pm

dtrace
 
User avatar
farmer
Posts: 61
Joined: December 16th, 2002, 7:09 am

How to monitor each thread behavior of a multithread (pthread) C++ program on Linux ?

January 26th, 2012, 5:56 pm

The biggest problem I have experienced is that logging the activity changes the timing of the threads. So if I had to do it today, I night make a really simple set of codes for certain events. I would then write those codes to a circular buffer, to be consumed by a monitor thread. The monitor thread would then write to a log file, or send over a socket to a monitoring program or something. Another program, maybe on another processor, would translate the codes into readable strings, in parallel vertical columns, one for each thread, with consistent timing across any horizontal rows.
 
User avatar
lexington
Posts: 0
Joined: November 16th, 2008, 5:04 am

How to monitor each thread behavior of a multithread (pthread) C++ program on Linux ?

January 30th, 2012, 3:43 am

link with ACE library and use its logging macros.