pthreads stack frame lock up detection
Hi,
I have a C program with 2 threads using pthreads, one thread at base level and one at higher priority that runs every 25ms on a SIGALRM timer.
I have some code in each thread to check whether the other thread has got stuck in a tight loop - i.e. in case there is a programming error. In this case I want to log where it got stuck and restart the program automatically.
Each thread kicks a watchdog every time it iterates.
For the high priority thread I simply check for a lock up in the SIGALRM handler and if the thread has locked then I do a backtrace to a file before I restart the program.
Similarly the SIGALRM handler can detect if the base thread has locked up - however my problem is finding out where it has locked. Is there a way of decoding the stack frame for a different pthread from the one that is running?
Alternatively, am I missing an easier way of detecting lock ups in a pthreads program?
|