From owner-freebsd-threads@FreeBSD.ORG Fri Sep 22 18:47:17 2006 Return-Path: X-Original-To: freebsd-threads@freebsd.org Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3EBFD16A403 for ; Fri, 22 Sep 2006 18:47:17 +0000 (UTC) (envelope-from belindat@us.ibm.com) Received: from e1.ny.us.ibm.com (e1.ny.us.ibm.com [32.97.182.141]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9B13043D49 for ; Fri, 22 Sep 2006 18:47:16 +0000 (GMT) (envelope-from belindat@us.ibm.com) Received: from d01relay02.pok.ibm.com (d01relay02.pok.ibm.com [9.56.227.234]) by e1.ny.us.ibm.com (8.13.8/8.12.11) with ESMTP id k8MIlFWM005686 for ; Fri, 22 Sep 2006 14:47:15 -0400 Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay02.pok.ibm.com (8.13.6/8.13.6/NCO v8.1.1) with ESMTP id k8MIlFQf186998 for ; Fri, 22 Sep 2006 14:47:15 -0400 Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id k8MIlFpL011830 for ; Fri, 22 Sep 2006 14:47:15 -0400 Received: from thompsonb (wecm-9-67-127-164.wecm.ibm.com [9.67.127.164]) by d01av02.pok.ibm.com (8.12.11.20060308/8.12.11) with SMTP id k8MIlDGe011765; Fri, 22 Sep 2006 14:47:15 -0400 MIME-Version: 1.0 Message-Id: <45142FAA.000003.01864@THOMPSONB> Date: Fri, 22 Sep 2006 14:47:06 -0400 (Eastern Daylight Time) X-Mailer: IncrediMail (5002253) From: "Belinda Thompson" X-FID: FLAVOR00-NONE-0000-0000-000000000000 X-Priority: 3 To: Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: pthread_cond_signal hang possible X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Belinda Thompson List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Sep 2006 18:47:17 -0000 Kernel: 2.6.5-7.244=0D glibc 2.3.2=0D =0D I am looking at an intermittent problem that appears to be pthread_cond_signal not returning. =0D =0D The mutex in question is only shared between two threads, one a read and = one a write thread for each "connection". =0D The mutex is protecting a queue that is filled by the RxThread...and drained by the TxThread.=0D =0D It looks like thread7 is unable to get the mutex back after being awakene= d from the pthread_cond_wait because thread8 is still holding it. =0D And..thread8 never returns from pthread_cond_signal to release the mutex.= =0D =0D Could thread8 have been preempted by thread7 preventing it from returning from the system call to wake the thread?=0D =0D Any ideas would be appreciated.=0D =0D The flow is simple and as follows:=0D =0D Thread7:=0D pthread_mutex_lock(mutex);=0D pthread_cond_wait(condition);=0D pthread_mutex_unlock(mutex)=0D =0D Thread8:=0D pthread_mutex_lock(mutex);=0D pthread_cond_signal(condition);=0D pthread_mutex_unlock(mutex);=0D =0D =0D The gdb output is as follows:=0D =0D [Switching to thread 7 (process 19955)]=0D #0 0x41ee8124 in __lll_lock_wait () from /lib/tls/libpthread.so.0=0D #1 0x41ee56fe in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/tls/libpthread.so.0=0D #2 0x41df89da in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/tls/libc.so= =2E6=0D #3 0x00405daa in TxThread ()=0D #4 0x41ee2a8c in start_thread () from /lib/tls/libpthread.so.0=0D #5 0x41dec714 in thread_start () from /lib/tls/libc.so.6=0D =0D [Switching to thread 8 (process 19954)]=0D #0 0x41ee5c54 in pthread_cond_signal@@GLIBC_2.3.2 () from /lib/tls/libpthread.so.0=0D #1 0x41df8992 in pthread_cond_signal@@GLIBC_2.3.2 () from /lib/tls/libc.= so 6=0D #2 0x00407514 in TransmitPacket ()=0D #3 0x0040f3b8 in QueueTx ()=0D #4 0x0040d51c in Transmit ()=0D #5 0x0041237c in msg_handler ()=0D #6 0x004083d6 in newmail()=0D #7 0x00402e8a in put_message ()=0D #8 0x00404138 in PutMail ()=0D #9 0x004084a0 in send_msg()=0D #10 0x004067c0 in RxThread ()=0D #11 0x41ee2a8c in start_thread () from /lib/tls/libpthread.so.0=0D #12 0x41dec714 in thread_start () from /lib/tls/libc.so.6