Multithreading problems

Marshall Crocker marshall at iconux.org
Thu Aug 3 15:14:03 UTC 2006


John Clark wrote:
>
> However, one must always put '<pthread.h> at the beginning of all code 
> which calls anything
> having to do with any libc or system call. 

Indeed I did not think know about that.  Fortunately, I do have 
<pthread.h> before any other includes. 

> The biggest problem I had with threaded apps is the abysmal support 
> gdb has for linuxthreads.
>
I agree, debugging is my biggest problem right now.  I have resorted to 
using print statements and I can now see the deadlock but it should not 
be happening.

thread1: locks semaphore, enters critical section, exits critical 
section, unlocks semaphore
thread 2: attempts to lock semaphore
thread 1: attempts to lock semaphore
deadlock

I know thread 2 does not lock the semaphore since there are other print 
statements after thread 2 does the unlock. It looks like to me that both 
threads block while waiting for the semaphore to be incremented even 
though thread 2 should not be blocking.

I probably should go back to mutexes assuming they will work now that 
I'm linking lpthread.

Thanks for the input, I really appreciate it.

Marshall



More information about the uClibc mailing list