当前位置:网站首页>死锁的条件及解决方法
死锁的条件及解决方法
2022-07-02 12:28:00 【lvhui321】
多个互相竞争资源的线程互相等待,造成永久阻塞的现象被称为死锁
死锁的条件
1.互斥性:共享资源只能被一个同一个线程占用
2.占有且等待:线程T已经获取到共享资源A,在等待共享资源B的时候未释放A
3.不可抢占:其他线程不能强行占有T占有的资源
4.循环且等待:线程 T1 等待线程 T2 占有的资源,线程 T2 等待线程 T1 占有的资源
破解死锁
可破解死锁条件除互斥性之外的三个条件 ,如下:
1.破坏“占用且等待”条件,可以一次性申请所有的资源,这样就不存在等待了。
2.破坏“不可抢占”条件,占用部分资源的线程进一步申请其他资源时,如果申请不到,可以主动释放它占有的资源,这样不可抢占这个条件就破坏掉了。
3.破坏“循环等待”条件,可以靠按序申请资源来预防。所谓按序申请,是指资源是有线性顺序
的,申请的时候可以先申请资源序号小的,再申请资源序号大的,这样线性化后自然就不存在循环
了。
边栏推荐
- 6096. Success logarithm of spells and potions
- /Bin/ld: cannot find -lssl
- [leetcode] 695 - maximum area of the island
- 中科大脑知识图谱平台建设及业务实践
- 愛可可AI前沿推介(7.2)
- College entrance examination score line climbing
- /bin/ld: 找不到 -llz4
- [salesforce] how to confirm your salesforce version?
- Make p12 certificate [easy to understand]
- 2279. 装满石头的背包的最大数量
猜你喜欢
2020.4.12 byte written test questions B DP D monotone stack
Crawl the information of national colleges and universities in 1 minute and make it into a large screen for visualization!
蚂蚁集团大规模图计算系统TuGraph通过国家级评测
Soul torture, what is AQS???
树-二叉搜索树
爱可可AI前沿推介(7.2)
Experiment collection of University "Fundamentals of circuit analysis". Experiment 7 - Research on sinusoidal steady-state circuit
【Experience Cloud】如何在VsCode中取得Experience Cloud的MetaData
[development environment] install Visual Studio Ultimate 2013 development environment (download software | install software | run software)
智联招聘的基于 Nebula Graph 的推荐实践分享
随机推荐
floyed「建议收藏」
解决BASE64Encoder报错的问题
PTA ladder game exercise set l2-001 inter city emergency rescue
已知兩種遍曆序列構造二叉樹
图数据库|Nebula Graph v3.1.0 性能报告
College entrance examination admission score line climbing
Nebula Graph & 数仓血缘关系数据的存储与读写
6090. 极大极小游戏
数组和链表的区别浅析
(Wanzi essence knowledge summary) basic knowledge of shell script programming
For the problem that Folium map cannot be displayed, the temporary solution is as follows
How to import a billion level offline CSV into Nepal graph
Fiddler实现手机抓包——入门
二叉树前,中,后序遍历
lseek 出错
动态规划入门一,队列的bfs(70.121.279.200)
Locate: cannot execute stat() `/var/lib/mlocate/mlocate Db ': there is no such file or directory
Use ffmpeg command line to push UDP and RTP streams (H264 and TS), and ffplay receives
Thoroughly understand browser strong cache and negotiation cache
How to use percona tool to add fields to MySQL table after interruption