How to avoid deadlocks?

前端 未结 8 864
隐瞒了意图╮
隐瞒了意图╮ 2021-02-01 03:30

When using multiple threads, shared memory needs to be locked by critical sections. However, using critical sections causes potential deadlocks. How can they be avoided?

8条回答
  •  深忆病人
    2021-02-01 03:59

    THE FOLLOWING ALGORITHM IS USED TO AVOID DEADLOCK:

    Banker’s Algorithm

    –Impose less stringent conditions than in deadlock prevention in an attempt to get better resource utilization

    –Safe state

    •Operating system can guarantee that all current processes can complete their work within a finite time

    –Unsafe state

    •Does not imply that the system is deadlocked, but that the OS cannot guarantee that all current processes can complete their work within a finite time

    –Requires that resources be allocated to processes only when the allocations result in safe states. –It has a number of weaknesses (such as requiring a fixed number of processes and resources) that prevent it from being implemented in real systems

提交回复
热议问题