📜  操作系统中死锁和饥饿的区别

📅  最后修改于: 2021-09-28 09:51:11             🧑  作者: Mango

僵局:
当每个进程持有一个资源并等待任何其他进程持有的其他资源时,就会发生死锁。发生死锁的必要条件是互斥、保持和等待、无抢占和循环等待。在这种情况下,没有进程持有一个资源并等待另一个被执行。例如,在下图中,进程 1 持有资源 1 并等待进程 2 获取的资源 2,进程 2 正在等待资源 1。因此进程 1 和进程 2 都处于死锁状态。

饥饿:
饥饿是当高优先级进程继续执行而低优先级进程无限期阻塞时发生的问题。在负载较重的计算机系统中,源源不断的高优先级进程可以阻止低优先级进程获得 CPU。在饥饿状态下,高优先级进程会持续利用资源。饥饿问题可以使用老化解决。在长时间等待进程的老化优先级逐渐增加。

死锁和饥饿的区别:

S.NO Deadlock Starvation
1. All processes keep waiting for each other to complete and none get executed High priority processes keep executing and low priority processes are blocked
2. Resources are blocked by the processes Resources are continuously utilized by high priority processes
3. Necessary conditions Mutual Exclusion, Hold and Wait, No preemption, Circular Wait Priorities are assigned to the processes
4. Also known as Circular wait Also know as lived lock
5. It can be prevented by avoiding the necessary conditions for deadlock It can be prevented by Aging