Deadlock Avoidance Algorithms in OS (Operating System) - Must be Known

Deadlock Avoidance Algorithms in OS (Operating System) – Must be Known

What is Deadlock Avoidance?

DefinitionDeadlock avoidance is the mostly used by several types of operating systems, but it is used mainly for end users. This concept is more comfortable for single user system because they use their system for simply browsing as well as other simple activities.  

Deadlock avoidance technique (method) helps to avoid deadlock to occur in the system. So, Wait for Graph technique is used for deadlock avoidance.

Wait for Graph Technique

Wait for Graph’s concept is used in the deadlock avoidance, but it can’t bear the large database, it is designed mainly for small databases.

Wait for graph

In the Wait for Graph,  to create the relationship in the among of resources and transactions. If, any time transaction is needed of resources then it fires the request for those resources, but that same time those resources are already hold by other transactions. Then they are persisted at the one edge on the Wait for Graph. So, If Wait for Graph is converted into cycle form then deadlock is happened into system, otherwise it is not persisted into system.

Safe State 

Whenever process fires the requests for available resource, then system must have to decide that if immediate allocations free the system in safe state.

System is in safe state if there exists a sequence <P1, P2, …, Pn> of ALL the processes in the systems such that for each Pi, the resources that Pi can still request can be satisfied by currently available resources + resources held by all the Pj, with j < I

Then is –

  • If, Pi resource does not require immediately available, then Pi have to wait until completely Pj have been finished.
  • Whenever Pj is getting ending, then Pi can receive required resources, execute, return allocated resources, and terminate.
  • If Pi terminates, then Pi+1 can get its required resources, and so on.

Primary Facts –

  • If system is getting in the safe state, then does not happen deadlock
  • If system is getting in the unsafe state, then may be occur deadlock
  • If ensure that system will never going to enter an unsafe state, then Avoidance is getting.

Deadlock Avoidance can be solved by two different algorithms, such as –

  • One instance of a resources type – To use a Resource Allocation Graph
  • Several instance of a resources type – To use Banker’s Algorithm

Resource Allocation Graph

In the Resource Allocation Graph, to represent of all states of system in the graphically form. Resource Allocation Graph contains the whole information related to all processes those are hold by few resources otherwise getting to wait for some resources.

resource allocation graph

Vertices have two varieties, Resource and Process. Every vertices is shown by different shape, such as Circle represents a process, and other side rectangle represents a resources.

Resources may be containing the multiple instances, and every instance will be represented by a dot inside the rectangle.

Banker’s Algorithm

Banker’s Algorithm is used to resource allocation and deadlock avoidance that determine to safety by simulating the allocation for predetermined maximum possible amounts of all resources, then makes an “s-state” check to test for possible activities, before deciding whether allocation should be allowed to continue.

Banker’s Algorithm is named because it is implemented in the banking sector, and main objective of using this algorithm is to check that loan can be sanctioned or not to clients.

Leave a Reply

Your email address will not be published. Required fields are marked *