Operating System—Deadlock: Handling Methods: Prevention, Avoidance, Detection and Recovery, Ignore

  • Analyzing Deadlock Problems
    • Reason: A process occupies a resource and requests a resource occupied by another process
    • Necessary conditions: mutual exclusion, occupy and wait, non-preemptive, circular wait
    • Resource application and use process: application, use, release
    • Resource allocation diagram:

  • prevention
    • Mutual exclusion: usually cannot be changed
    • Occupy and wait: all resources are prepared before the process is executed; or the previous one is released when the next one is applied for. May cause hunger problems
    • Non-preemptive: If a process occupies a resource and requests another resource that cannot be allocated, the allocated resource can be preempted
    • Circular waiting: set the resource application sequence, and apply for release in sequence
  • Avoid: Make sure the system does not enter an unsafe state
    • Resource Allocation Diagram: Introducing the Demand Side
    • Banker's Algorithm:

      • security algorithm
      • Resource Request Algorithm
  • Detection: The call depends on how often deadlocks occur and how many processes are affected when a deadlock occurs
    • wait graph
    • banker's algorithm
  • Recovery: choose victims and take into account starvation, avoid always the same process being the victim

Guess you like

Origin blog.csdn.net/qq_56061892/article/details/126224109