c 递归锁(重入锁) pthread_cond_wait 死锁
来源:互联网 发布:json文件的注释 编辑:程序博客网 时间:2024/06/16 10:19
//1 thread
pthread_mutex_lock(&mutex);
pthread_mutex_lock(&mutex);
pthread_cond_wait(&cond, &mutex);
pthread_mutex_unlock(&mutex);
pthread_mutex_unlock(&mutex);
//2 thread
pthread_mutex_lock(&mutex);
pthread_cond_signal(&mutex);
pthread_mutex_unlock(&mutex);
//3 init
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
pthread_mutex_init(&mutex, &attr);
先执行1 thread,然后执行2 thread,会发现在锁定1 thread后,进行pthread_cond_wait操作后,会导致死锁
猜想,应该是pthread_cond_wait只会解锁一层mutex,最后还有一层锁定状态,导致死锁状态
另还有文档说明不要使用pthread_cond_wait在递归锁(重入锁)中
0 0
- c 递归锁(重入锁) pthread_cond_wait 死锁
- C pthread_cond_wait
- python基础-死锁、递归锁
- 互斥锁、死锁、递归锁、信号量、Event
- pthread_cond_wait的锁操作
- pthread_cond_wait()
- pthread_cond_wait
- pthread_cond_wait
- pthread_cond_wait
- pthread_cond_wait()
- pthread_cond_wait()
- pthread_cond_wait
- pthread_cond_wait
- pthread_cond_wait()
- pthread_cond_wait()
- pthread_cond_wait()
- pthread_cond_wait()
- pthread_cond_wait
- ElasticsearchCRUD使用(十五)【批量插入数据】
- 超级加法
- Oracle常用语句大全
- 写一个线段树的复习吧,撑撑门面感觉blog里东西好水,,,过几天写几道省选-的题。。
- 数据库第三部分
- c 递归锁(重入锁) pthread_cond_wait 死锁
- Java中的类和对象【二】
- Java思维导图(1)--Java概览及面向结构部分
- 类 Hashtable<K,V>及与HashMap的区别
- python基础-----内置函数
- 修改WAMPServer默认的网站路径地址
- STM32F系列ARM Cortex-M3核微控制器基础之存储系统一
- IE8打开https显示找不到网站,chrome打开正常
- ElasticsearchCRUD使用(十六)【Elasticsearch聚合】