Explain Deadlock Modelling and Strategies along with an example

As stated in previous topic, in Deadlock situation, a process waits resources which are using by other process without releasing its own resources. It is therefore causes all the processes waiting and waiting for the resources of each other; hence it brings critical condition to make deadlock condition.

In this chapter, we are going to model deadlock condition by using directed graph. Here we use directed graph to show whether it is requesting resources or holding resources. And circle are used to denote process whereas rectangle refers the resources.

Deadlock Modelling
Fig: Block Diagram of Deadlock Modelling
Above diagram shows the modelling process of deadlock, it shows requesting and holding of resources in/from a process. In the figure, A process is requesting T resource one time. In the bottom fig, A is holding T resource.

In fact, there is not solution of deadlock condition, that is why it is known as non-resolving situation. But a good programmer must be known with this fact before working on any project. S/he must be careful about the dealing of deadlock. A programmer has to consider 4 strategies to deal with deadlock. They are as follows:

  1. Ignoring the deadlock problem
  2. Detection and Recovery
  3. Avoiding Dynamically with Resource Allocation
  4. Prevention of Deadlock
Above four strategies are common and most important part of a programmer. S/he must apply one of these strategies which helps them to deal with deadlock. But among them prevention and dynamic avoidance are the best away of dealing with deadlock because it does not let deadlock condition to occur in a task like the speech "Prevention is better than cure". 

Ignoring can not be solution of any problem; ignoring of that problem obviously damages and lose something of your task. Detection and recovery somewhat can get back your data and information by detecting that deadlock. Allocating resources carefully in the different processes, a programmer can keep away the task out of the deadlock condition dynamically.

Post a Comment