Deadlock conditions and the solution

 

  • Deadlock condition
    must exist at the same time the following four conditions to deadlock.

    1. Mutually exclusive conditions
      that is a resource can only be occupied by one process at a time, it can not be two or more processes possession. After this exclusive resources such as CD-ROM drives, printers, and so on, must take the initiative to release it in the process of possession of the resources, other processes can occupy the resource. This is determined by the properties of the resource itself.
    2. Can not be preempted conditions.
      Resources obtained before the process is complete unused resources the applicant can not forcibly seize resources from the hands of the occupant, and the process can only be released by the occupant of the property yourself.
    3. Possession and application conditions.
      At least the process has occupied a resource, but to apply new resources; resources have been due to the possession of another process, the process is blocked at this time; however, it while waiting for new resources, the continued occupation of resources have been occupied.
    4. Loop wait condition
      exists process waits for a sequence {P1, P2, ..., Pn }, where P1 P2 waiting for a resource occupied, P2 P3 occupied by waiting a source, ......, Pn and P1 is waiting for a resource occupied, the process of forming a loop waiting for the ring.
  • Deadlock prevention of
    deadlock prevention is a strategy to ensure that the system does not enter a deadlock state.

  1. Destruction of mutually exclusive conditions
    some resources can not be shared. - useless
    2. destruction can not be preempted conditions.
    Preemptive, which requires the application process failed to release resources to others with their own possession, degrade system performance.
    3. destruction of possession and application conditions.
    Directly apply all the resources they need. - 1. unpredictable what resources they need 2. resource utilization is low, long-term possession that he might not have the resources.
    4. The cycle of destruction wait condition
    resource classification, numbering, sequential application. - · No. 1 may be difficult to maintain the corresponding sequence is difficult
  • Avoid deadlock
    avoid deadlock means that the command does not limit the process of the application of resources, but rather as a resource for each application process command issued dynamically check and decide whether to allocate resources according to test results.
    Banker's algorithm. When a process application resource usage, bankers algorithm to test the resources allocated to that process, then the system after the judge assigned by the security algorithm is in a safe state, if the safety tentative allocation set aside, let the process continue to wait.

Determining the security status of the allocated resources required, required resources, available resources, determining symbol Finish

Guess you like

Origin www.cnblogs.com/liangyc/p/11628210.html