pthread_cond_signal hang possible

Belinda Thompson belindat at us.ibm.com
Fri Sep 22 11:47:17 PDT 2006


Kernel:  2.6.5-7.244
glibc 2.3.2
 
I am looking at an intermittent problem that appears to be
pthread_cond_signal not returning.  
 
The mutex in question is only shared between two threads, one a read and one
a write thread for each "connection".  
The mutex is protecting a  queue that is filled by the RxThread...and
drained by the TxThread.
 
It looks like thread7 is unable to get the mutex back after being awakened
from the pthread_cond_wait because thread8 is still holding it.  
And..thread8 never returns from pthread_cond_signal to release the mutex.
 
Could thread8 have been preempted by thread7 preventing it from returning
from the system call to wake the thread?
 
Any ideas would be appreciated.
 
The flow is simple and as follows:
 
Thread7:
  pthread_mutex_lock(mutex);
  pthread_cond_wait(condition);
  pthread_mutex_unlock(mutex)
 
Thread8:
  pthread_mutex_lock(mutex);
  pthread_cond_signal(condition);
  pthread_mutex_unlock(mutex);
 
 
The gdb output is as follows:
 
 [Switching to thread 7 (process 19955)]
#0  0x41ee8124 in __lll_lock_wait () from /lib/tls/libpthread.so.0
#1  0x41ee56fe in pthread_cond_wait@@GLIBC_2.3.2 ()    from
/lib/tls/libpthread.so.0
#2  0x41df89da in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/tls/libc.so.6
#3  0x00405daa in TxThread ()
#4  0x41ee2a8c in start_thread () from /lib/tls/libpthread.so.0
#5  0x41dec714 in thread_start () from /lib/tls/libc.so.6

[Switching to thread 8 (process 19954)]
#0  0x41ee5c54 in pthread_cond_signal@@GLIBC_2.3.2 ()    from
/lib/tls/libpthread.so.0
#1  0x41df8992 in pthread_cond_signal@@GLIBC_2.3.2 () from /lib/tls/libc.so
6
#2  0x00407514 in TransmitPacket ()
#3  0x0040f3b8 in QueueTx ()
#4  0x0040d51c in Transmit ()
#5  0x0041237c in msg_handler ()
#6  0x004083d6 in newmail()
#7  0x00402e8a in put_message ()
#8  0x00404138 in PutMail ()
#9  0x004084a0 in send_msg()
#10 0x004067c0 in RxThread ()
#11 0x41ee2a8c in start_thread () from /lib/tls/libpthread.so.0
#12 0x41dec714 in thread_start () from /lib/tls/libc.so.6


More information about the freebsd-threads mailing list