f******e 发帖数: 164 | 1 【 以下文字转载自 Linux 讨论区 】
发信人: francise (小飞猫), 信区: Linux
标 题: 如何GDB调试因pthread_cond_wait()阻塞的线程?
发信站: BBS 未名空间站 (Thu Apr 3 02:08:42 2008)
比如有两个线程1,2,主线程1执行到某处会pthread_cond_wait(),然后由线程2唤醒
,继续执行.
我用gdb调试时却出了问题,调试时主线程执行到pthread_cond_wait()函数处
,进入等待状态,ctrl+c后看到的线程信息如下:
(gdb) info thread
* 3 Thread 1026 (LWP 19165) 0x420292e5 in sigsuspend ()
from /lib/i686/libc.so.6
2 Thread 2049 (LWP 19164) 0x420e0037 in poll () from
/lib/i686/libc.so.6
| v*****x 发帖数: 8 | 2 pthread_cond_wait only waits for signal happens after.
So, the correct sequence is:
thread 1 waits (suspends)
thread 2 signals
thread 1 proceeds.
In your scenario:
thread 2 signals (which makes you assume thread 1 should return immediately
from a subsequent wait)
thread 1 waits (suspends indefinitely until next time thread 2 signals)
For more information, refer to pthread reference.
)
【在 f******e 的大作中提到】 : 【 以下文字转载自 Linux 讨论区 】 : 发信人: francise (小飞猫), 信区: Linux : 标 题: 如何GDB调试因pthread_cond_wait()阻塞的线程? : 发信站: BBS 未名空间站 (Thu Apr 3 02:08:42 2008) : 比如有两个线程1,2,主线程1执行到某处会pthread_cond_wait(),然后由线程2唤醒 : ,继续执行. : 我用gdb调试时却出了问题,调试时主线程执行到pthread_cond_wait()函数处 : ,进入等待状态,ctrl+c后看到的线程信息如下: : (gdb) info thread : * 3 Thread 1026 (LWP 19165) 0x420292e5 in sigsuspend ()
|
|