Re: debugging or tracing a multi-threaded program
- From: darren <minofifa@xxxxxxxxx>
- Date: Thu, 21 Aug 2008 23:30:24 -0700 (PDT)
On Aug 21, 11:20 pm, sam.n.seab...@xxxxxxxxx wrote:
Hi all,
I am writing a multi threaded app (basically a small HTTP server that
uses threadpools) and stress testing it with 20-30 simultaneous client
connections (sort of like apachebench). (This is on AIX 5.3.)
The basic design is around a main thread (that accepts client conns
and select()'s over them to detect client activity) and a bunch of
worker threads (that process one transaction and return to the pool to
idle). I am experimenting with this and other multiprocess/multithread
models.
I'm facing issues around mutex locking, pthread_cond_wait, and in some
cases the server just stops, possibly due to either deadlock or maybe
something else. To try and get to the bottom of this, I'm used
printf()s, then went to using write()s to a debug file, but I feel
both are too slow or otherwise unreliable. I guess my basic problem is
to trace through the thread activity to see which threads get woken up
when, and what they do.
My questions is: is there a good i.e. reliable and efficient way to
trace the execution of the program i.e. when threads become active and
when they return? In my case, threads are woken up by signals and they
restore the mask when they go back to idling. I have googled and RTMs
of GDB, DBX and others, but they only go as far as to indicate when
threads are created or are exiting e.g. GDB print thread-events. Also,
debuggers give a snapshot view instead of an execution view: typing
"threads" or "lwps" into dbx shows snapshots of what all the threads
are doing, and it's hard to piece these snapshots together to find out
what's happening from start to end.
I am guessing there are probably 3 alternatives:
1. write a debugger script that takes these snapshots at high speed
and dumps them somewhere; but will that perturb the actual application
too much?
2. fast write() in the app, but how to synchronize across threads? yet
another lock, causing more perturbation?
3. app writes out debug messages to a socket that is read by another
reader app; but will the OS (AIX 5.3) guarantee that concurrent
write()s by different threads will be delivered in order?
Any other suggestions or hints would be appreciated.
thanks in advance,
-SNS
hi
this may not be the answer you are looking for, but have you ever used
static analysis tools? I recently found a tool called findbugs that
looks over your java source code and points out anything sketchy you
may be doing A friend told me about some similar tools they were
using, a few of which supported multithreaded applications. This post
reminded me of them. Maybe you could google for threaded static
analysis tools to find something to help you?
.
- Prev by Date: Re: Entry point
- Next by Date: Re: How to check the status of a directory in C under Unix?
- Previous by thread: reading from a file and writing to other using pipe
- Next by thread: Re: debugging or tracing a multi-threaded program
- Index(es):
Relevant Pages
|