concurrency - 死锁和无限期推迟有什么区别?

标签 concurrency

死锁 - 两个或多个相互竞争的 Action 都在等待对方完成的情况,因此两者都没有。

无限期推迟 - 无限期延迟一个进程的调度,而其他进程受到系统的关注

这两个术语看起来非常相似。我如何区分它们?

最佳答案

In any system that keeps processes waiting while it makes resource-allocation and process scheduling decisions, it is possible to delay indefinitely the scheduling of a process while other processes receive the system's attention. This situation, variously called indefinite postponement, indefinite blocking, or starvation, can be as devastating as deadlock



从:

http://wps.prenhall.com/esm_deitel_os_3/17/4402/1127072.cw/index.html

哈文德的死锁条件(1968) - 7.2.1

• There is a circular list of processes each wanting a resource owned by another in the list.

• Resources cannot be shared.

• Only the owner can release the resource

• A process can hold a resource while requesting another



从:

http://www.cs.auckland.ac.nz/~robert-s/415.340/lectures_1997/lecture35.pdf

所以无限延迟导致1个进程受到影响而其他进程正常继续,这可能是由于调度不佳或其他原因造成的,即无限延迟的进程始终比同一资源后的所有其他进程具有更低的优先级。在稍后的某个时间,它可能最终获得足够高的优先级来获取资源。

当一个进程请求另一个进程持有的资源时会导致死锁。那个进程 (A) 不会释放资源,直到它得到它正在请求的另一个资源,顺便说一句,另一个进程 (B) 不会释放它,直到它收到另一个进程 (C) 持有的资源不会释放它,直到它得到 (A) 持有的资源。该场景涉及 3 个流程,A、B、C;但它可能涉及 2 个或更多进程的任何“循环”。

关于concurrency - 死锁和无限期推迟有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19482820/

相关文章:

c++ - 为什么锁定 std::mutex 不会阻塞线程

c++ - 何时在多线程中使用 volatile ?

java - 避免事件总线中的 ConcurrentModificationException

java - 什么时候应该使用 CompletionService 而不是 ExecutorService?

java - 关闭执行器服务中的线程而不关闭它

MySQL 多个事务递增同一行

Java - 在 JPanel 中获取选择的选项而不进行轮询

goroutine 等待 channel 的响应并继续

java - Java 中是否有在方法级别同步访问对象的设计模式或最佳实践?

c - c 中的 pthreads 返回意外结果