- 論壇徽章:
- 1
|
回復(fù) 3# 阿注哥
看到thrd_cleanup()清理函數(shù)沒有執(zhí)行,所以阻塞應(yīng)該發(fā)生在清理函數(shù)調(diào)用之前。查看pthread_cond_wait()函數(shù)的源碼發(fā)現(xiàn)如下代碼:- /* Before we block we enable cancellation. Therefore we have to
- install a cancellation handler. */
- __pthread_cleanup_push (&buffer, __condvar_cleanup, &cbuffer);
復(fù)制代碼 也就是在自定義清理函數(shù)執(zhí)行之前,nptl先執(zhí)行__condvar_cleanup()函數(shù),查看__condvar_cleanup()函數(shù)源碼有如下實現(xiàn):- /* Get the mutex before returning unless asynchronous cancellation
- is in effect. */
- __pthread_mutex_cond_lock (cbuffer->mutex);
復(fù)制代碼 這里應(yīng)該是造成死鎖的地方。不知與您說的是否一致? |
|