avatar
l*b
2
不太懂。。。deadlock和语言关系不大吧,都是对thread和数据加锁来实现
avatar
a*1
3
哦。
那有什么办法可以 避免啊?
avatar
g*e
4
there are 4 conditions, all of which have to be satisfied for deadlock to
happen.
A deadlock situation can arise if and only if all of the following
conditions hold simultaneously in a system:[1]
Mutual Exclusion: At least one resource must be non-shareable.[1] Only one
process can use the resource at any given instant of time.
Hold and Wait or Resource Holding: A process is currently holding at least
one resource and requesting additional resources which are being held by
other processes.
No Preemption: The operating system must not de-allocate resources once they
have been allocated; they must be released by the holding process
voluntarily.
Circular Wait: A process must be waiting for a resource which is being held
by another process, which in turn is waiting for the first process to
release the resource. In general, there is a set of waiting processes, P = {
P1, P2, ..., PN}, such that P1 is waiting for a resource held by P2, P2 is
waiting for a resource held by P3 and so on till PN is waiting for a
resource held by P1.[1][7]
These four conditions are known as the Coffman conditions from their first
description in a 1971 article by Edward G. Coffman, Jr.[7] Unfulfillment of
any of these conditions is enough to preclude a deadlock from occurring.
avatar
c*s
5
There are many ways to do this. Here is one way which always works.
For each thread, let it acquire all locks in the same order.
For example, thread 1 always acquire lock 1, then lock 2, then lock 3, and
the same for all other threads.
Please refer to slide 14 below for this technique:
http://www.cs.umd.edu/class/fall2012/cmsc433/0101/lecture-notes
avatar
c*s
6
There are many ways to do this. Here is one way which always works.
For each thread, let it acquire all locks in the same order.
For example, thread 1 always acquire lock 1, then lock 2, then lock 3, and
the same for all other threads.
Please refer to slide 14 below for this technique:
http://www.cs.umd.edu/class/fall2012/cmsc433/0101/lecture-notes
avatar
W*g
7
always acquire locks in order.

【在 a*****1 的大作中提到】
: 请高手解答。。
: 怎么做比较好 啊?
: 谢谢。

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。