What is deadlock? State the conditions necessary for deadlock to exit. Give reason, why all conditions are necessary.



Deadlock can be defined formally as: A set of processes is deadlocked if each process in the set is waiting for an event that only another process in the set can cause. Because all the processes are waiting, none of them will ever cause any of the events that could wake up any of the other members of the set, and all the processes continue to wait forever. Here below are the four conditions which must be present for a deadlock to occur. If one of them is absent, no deadlock is possible.

  •  Mutual exclusion condition: Each resource is either currently assigned to exactly one process or is available.

      Hold and wait condition: Processes currently holding resources granted earlier can request new resources.

      No preemption condition: Resources previously granted cannot be forcibly taken away from a process. They must be explicitly released by the process holding them.

      Circular wait condition: There must be a circular chain of two or more processes, each of which is waiting for a resource held by the next member of the chain.
  • In general, four strategies are used for dealing with deadlocks. They are:
  •   Just ignore the problem altogether. Maybe if you ignore it, it will ignore you.
  •   Detection and recovery: Let deadlocks occur, detect them, and take action.
  •   Dynamic avoidance by careful resource allocation.
  •   Prevention: by structurally negating one of the four conditions necessary to cause a
    deadlock.

0 comments:

Feel free to contact the admin for any suggestions and help.