Deadlock in dbms

misk5500 1,024 views 11 slides Dec 16, 2017
Slide 1
Slide 1 of 11
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11

About This Presentation

A deadlock is a condition where two or more tasks are waiting for each other in order to be finished but none of the task is willing to give up the resources that other task needs. In this situation no task ever gets finished and is in waiting state forever.
e.g: Quiz,pen,page.


Slide Content

Deadlock in DBMS Muhammad Ilyas khan Bcs-soft-7 th batch 1 st Roll # 23

What Is This?

deadlock A  deadlock  is a condition where two or more tasks are waiting for each other in order to be finished but none of the task is willing to give up the resources that other task needs. In this situation no task ever gets finished and is in waiting state forever. e.g : Quiz,pen,page .

deadlock

Coffman Conditions Coffman stated four conditions for a deadlock occurrence. A deadlock may occur if all the following conditions holds true .

Coffman Conditions, Cont… Mutual exclusion condition : There must be at least one resource that cannot be used by more than one process at a time. Hold and wait condition : A process that is holding a resource can request for additional resources that are being held by other processes in the system. No preemption condition : A resource cannot be forcibly taken from a process. Only the process can release a resource that is being held by it. Circular wait condition : A condition where one process is waiting for a resource that is being held by second process and second process is waiting for third process ….so on and the last process is waiting for the first process. Thus making a circular chain of waiting .

For Example Assume a set of transactions { T , T 1 , T 2 , ...,T n }. T needs a resource X to complete its task. Resource X is held by T 1 , and T 1 is waiting for a resource Y, which is held by T 2 . T 2 is waiting for resource Z, which is held by T . Thus, all the processes wait for each other to release resources. In this situation, none of the processes can finish their task. This situation is known as a deadlock.

Deadlock Prevention DBMS aggressively inspects all the operations, where transactions are about to execute. The DBMS inspects the operations and analyzes if they can create a deadlock situation. If it finds that a deadlock situation might occur, then that transaction is never allowed to be executed.

There are deadlock prevention schemes that use timestamp ordering mechanism of transactions in order to predetermine a deadlock situation.

Wait-die Scheme In this scheme, if a transaction requests to lock a resource (data item), which is already held with a conflicting lock by another transaction, then one of the two possibilities may occur − If TS( Ti ) < TS( Tj ) − that is Ti , which is requesting a conflicting lock, is older than Tj − then Ti is allowed to wait until the data-item is available. If TS( Ti ) > TS( tj ) − that is Ti is younger than Tj − then Ti dies. Ti is restarted later with a random delay but with the same timestamp. This scheme allows the older transaction to wait but kills the younger one.

Thanks