0

我正在使用在共享内存中定义的递归互斥锁用于两个进程之间的同步。我看到两个进程之间出现死锁,但是当我调试核心文件时,我发现进程 A 和进程 B 都没有拥有锁,但都试图获取锁。我们可以在下面看到,在这两个进程中,锁的所有者都是 0。

过程一:

(gdb) bt
#0  0x0fb4e06c in __pthread_mutex_lock_full (mutex=0x4583efa4) at ../nptl/pthread_mutex_lock.c:310
#1  0x0fb4e31c in __GI___pthread_mutex_lock (mutex=mutex@entry=0x4583efa4) at ../nptl/pthread_mutex_lock.c:73
(gdb) p *mutex
$3 = {__data = {__lock = -2147483648, __count = 0, __owner = 0, __kind = 145, __nusers = 0, {__elision_data = {__espins = -18453, __elision = -24448}, __list = {
        __next = 0xb7eba080}}}, __size = "\200", '\000' <repeats 14 times>, "\221\000\000\000\000\267\353\240\200", __align = -2147483648}
(gdb)

过程乙:

(gdb) 
#0  0x0fb4e06c in __pthread_mutex_lock_full (mutex=0x4583efa4) at ../nptl/pthread_mutex_lock.c:310
#1  0x0fb4e31c in __GI___pthread_mutex_lock (mutex=mutex@entry=0x4583efa4) at ../nptl/pthread_mutex_lock.c:73
(gdb) p *mutex
$3 = {__data = {__lock = -2147483648, __count = 0, __owner = 0, __kind = 145, __nusers = 0, {__elision_data = {__espins = -18453, __elision = -24448}, __list = {
        __next = 0xb7eba080}}}, __size = "\200", '\000' <repeats 14 times>, "\221\000\000\000\000\267\353\240\200", __align = -2147483648}
(gdb)

这对我来说似乎很奇怪,我可以知道你的第一个想法是什么吗?

有人可以给我一些关于它的信息吗?

4

0 回答 0