Deadlock prevantion in dbms

            Deadlock prevantion

  • For large database , deadlock prevantion method is suitable. 
  • A deadlock can be prevented if the resources are allocated in such a way that deadlock never occur.
  •  The DBMS analyzes the operations whether they can create deadlock situation or not, If they do, that transaction is never allowed to be executed.

Deadlock prevention mechanism proposes two schemes :

Wait-Die Scheme –

  • In this scheme, If a transaction request for a resource that is locked by other transaction, then the DBMS simply checks the timestamp of both transactions and allows the older transaction to wait until the resource is available for execution.
  • Suppose, there are two transactions T1 and T2 and Let timestamp of any transaction T be TS (T).
  •  Now, If there is a lock on T2 by some other transaction and T1 is requesting for resources held by T2, then DBMS performs following actions:
  • Checks if TS (T1) < TS (T2) – if T1 is the older transaction and T2 has held some resource, then it allows T1 to wait until resource is available for execution.
  •  That means if a younger transaction has locked some resource and older transaction is waiting for it, then older transaction is allowed wait for it till it is available.
  •  If T1 is older transaction and has held some resource with it and if T2 is waiting for it, then T2 is killed and restarted latter with random delay but with the same timestamp. 
  • i.e. if the older transaction has held some resource and younger transaction waits for the resource, then younger transaction is killed and restarted with very minute delay with same timestamp.
  • This scheme allows the older transaction to wait but kills the younger one.

Wound wait scheme :-


  • In this scheme, if an older transaction requests for a resource held by younger transaction, then older transaction forces younger transaction to kill the transaction and release the resource.
  •  The younger transaction is restarted with minute delay but with same timestamp. If the younger transaction is requesting a resource which is held by older one, then younger transaction is asked to wait till older releases it.

Thank you viewers .if this article is helpful for you then pls share with your friends and follow our website.
This is published by soumy Sinha..

Comments

Popular posts from this blog

Introduction of Digital computer

INTRODUCTION OF DBMS

Introduction to cache memory