Sie sind auf Seite 1von 26

Deadlock Detection & Recovery

A PROJECT REPORT ON

Deadlock Detection & Recovery


SUBMITTED BY

Mr. SANDEEP SHAMRAO NAIK Mr. GANESH DI A!E "S#M$A% Se&.III'


UNDER T E !UIDENCE O" M(. )HAG#ASHREE SUBMITTED TO UNI#ERSITY O$ PUNE AS A PARTIA% $U%$I%%MENT $OR T E A&ARD O$ T E DE!REE 'MASTER O$ COMPUTER APP%ICATION (M)C)A (Sci**+ T ROU! T E PRINCIPA% ASM,S CO%%E!E O$ COMMERCE- SCIENCE & IN$ORMATION TEC NO%O!YC INC &AD- PUNE . /00102 (3103 4 3105*

CSIT CO%%E!E C INC &AD) SYMCA (SCI* Se64III

Deadlock Detection & Recovery

A$KNO

*EDGEMEN!

e +ave ,reat -lea(.re in -re(entin, t+i( -ro/ect entitled Deadlock Detection &Recovery.

&e t7ank"8lly ackno9led:e t7e 7el; t7at 9e 7ave o<tained "ro6 teac7er= o" COMPUTER SCIENCE DEPARTMENT "or t7eir =8;;ort and co4o;eration ri:7t "ro6 t7e =ta:e t7e ;ro>ect 9a= conceived) T7e >o8rney o" t7i= ;ro>ect "ro6 conce;tion to co6;letion 9a= ;o==i<le d8e to Pro0. Mr(. )+a,ya(+ree Mada& "or :ivin: 8= val8a<le in"or6ation a<o8t t7e i6;le6entation o" t7e ;ro>ect) A =;ecial t7ank= to Pro0. Mr(. Priya Mada& " ead o" MCA (Science* de;art6ent* "or 7i= 7el; and ;rovidin: 8= :ood la<oratory "acility) %a=t <8t not lea=t- 9e 9o8ld like to e?;re== o8r =incere :ratit8de to t7o=e 97o 7ave 7el;ed 8= directly or indirectly in o8r ;ro>ect)

CSIT CO%%E!E C INC &AD) SYMCA (SCI* Se64III

Deadlock Detection & Recovery

DE$*ARA!ION
I 8nder=i:ned Sandee- Naik and Gane(+ Di1ate 7ere <y declare= t7at t7e ;ro>ect 9ork entitled 'Deadlock Detection & Recovery+ i= cond8cted 8nder t7e :8idance o" M=) P) B7a:ya=7ree) It i= 6y ori:inal 9ork and 7a= not <een co;ied "ro6 any ot7er =o8rce or ;ro>ect 9ork =8<6itted to t7e Univer=ity)

Date@

Na6e & Si:n o" St8dent (Mr. Sandee- Naik Mr. Gane(+ Di1ate*

CSIT CO%%E!E C INC &AD) SYMCA (SCI* Se64III

Deadlock Detection & Recovery

IN!ROD2$!ION
HA! IS D)MS

A data<a=e i= a collection o" data ty;ically de=cri<in: t7e activity o" on one or 6ore related or:aniAation) BDATABASE MANA!EMENT SYSTEM, i= a collection o" interrelated data and =et o" ;ro:ra6= to acce== t7o=e data A ;ri6ary :oal o" t7e DBMS i= to ;rovide convenient and

e""icient 9ay= to retrieve & =tore data<a=e in"or6ation)

DEAD*O$K DE!E$!ION & RE$O3ER# T7e conce;t o" tran=action ;rovide= a 6ec7ani=6 "or de=cri<in: lo:ical 8nit= o" data<a=e ;roce==in: t7at incl8de one or 6ore data<a=e acce== o;eration= like in=ertion- deletion- 6odi"ication- or retrieval) Tran=action ;roce==in: =y=te6= are =y=te6= 9it7 lar:e data<a=e= and 78ndred= o" conc8rrent 8=er= t7at are e?ec8tin: data<a=e tran=action=) A data<a=e i= <a=ically re;re=ented a= a collection o" na6ed data ite6=) It can <e a "ield o" =o6e record in t7e data<a=e or it can <e a record or even a 97ole di=k <lock) U=in: t7i= =i6;li"ied data<a=e 6odel- t7e <a=ic data<a=e
CSIT CO%%E!E C INC &AD) SYMCA (SCI* Se64III /

Deadlock Detection & Recovery

acce== o;eration= t7at a tran=action can incl8de are a= readCite6(D* and 9riteCite6(D*) A tran=action incl8de= readCite6 and 9riteCite6 o;eration= to acce== and 8;date t7e data<a=e) Conc8rrency control and recovery 6ec7ani=6= are 6ainly concerned 9it7 t7e data<a=e acce== co66and= in a tran=action) Tran=action= =8<6itted <y t7e vario8= 8=er= 6ay e4ec.te conc.rrently and 6ay acce== and 8;date t7e =a6e data<a=e ite6= =o it 6ay create a deadlock) T7e tran=action= involved in t7e deadlock- 6ake no "8rt7er ;ro:re==) &or=et7ey 7old lock= t7at 6ay reE8ire <y ot7er tran=action= =o t7e DBMS eit7er ;revent or detect and re=olve =8c7 deadlock =it8ation=) In DBMS- t7ere are =o6e ;olicie= like &ait4die and &o8nd49ait to ;revent t7e deadlock) A &ait4$or !ra;7 i= 8=ed to detect a deadlock) T7e ;olicie= like A<ortin: and Roll <ackin: o" tran=action= i= 8=ed to re=olve a deadlock) In o8r ;ro>ect- 9e 6ainly "oc8= on t7e di""erent ;olicie= o" =electin: a victi6 tran=action and deadlock recovery) &e 7one=tly try to i6;le6ent =o6e o" t7e al:orit76 8=ed <y t7e DBMS "or =electin: a victi6 tran=action and to recover "ro6 a deadlock)

CSIT CO%%E!E C INC &AD) SYMCA (SCI* Se64III

Deadlock Detection & Recovery

Pre(ent Sy(te&
Deadlock
A Sy=te6 i= in a deadlock =tate i" t7ere e?i=t a =et o" tran=action =8c7 t7at every tran=action in t7e =et i= 9aitin: "or tran=action in t7e =et $or6ally =tatin: -t7ere e?i=t= a =et o" 9aitin: tran=action GT1-T0-T3H =8c7 t7at T1 i= 9aitin: "or data ite6 i= 7eld <y T0 - and T0 i= 9aitin: "or data ite6 t7at i= 7eld <y T3 - and T(n40* i= 9aitin: "or data ite6 t7at i= 7eld <y Tn - and Tn i= 9aitin: "or data ite6 t7at i= 7eld <y T1) Deadlock Detection A deadlock detection =c7e6e i= tec7niE8e 97ere 9e allo9 t7e =y=te6 enter t7e dead lock =tate )

T0

T3

T0

T3

T5

T5

Deadlock State

NO Deadlock

CSIT CO%%E!E C INC &AD) SYMCA (SCI* Se64III

Deadlock Detection & Recovery

PROPOSED S#S!EM
In o8r =y=te6 vario8= tran=action= are :iven t7ro8:7 "ile=) T7e

tran=action are e?ec8ted in an interleave "a=7ion) So i" any tran=action :et =tr8ct t7at 6ean= dead lock 7a= accord) T7e =y=te6 detect t7e deadlock- t7e ne?t =te; i= to re6ove deadlock) So 9e =elect t7e victi6 tran=action) T7e victi6 tran=action i= a<orted and all lock= acE8ired <y t7e tran=action are relea=ed and allocated to ot7er tran=action=) T7e a<orted tran=action i= a:ain =tarted ne9ly) T7e ;ro:ra6= 6ainly 9ork= in t7ree =te;= a= @

0) 3) 5)

Detect t7e deadlock) Select t7e victi6 tran=action) Recover t7e deadlock)

CSIT CO%%E!E C INC &AD) SYMCA (SCI* Se64III

Deadlock Detection & Recovery

S$OPE O5 PRO6E$!

Incl.(ion
T7e 8=er 6ay =8<6it= one or 6ore t7an one tran=action at a ti6e) In o8r =y=te6- t7e=e tran=action= are e?ec8ted conc8rrently in interleaved "a=7ion) A"ter readin: every o;eration- t7e =y=te6 8;date= t7e %ockTa<le) I" any tran=action 8na<le to :et a lock on any o<>ect t7en t7e =y=te6 8;date= t7e &ait$or !ra;7 Ta<le "or t7e tran=action 97ic7 :oe= in 9aitin: =tate <eca8=e =o6e anot7er tran=action 7ave a lock on t7at o<>ect) A"ter t7i==y=te6 c7eck= "or t7e deadlock) I" deadlock occ8r=- =y=te6 =elect= t7e victi6 accordin: to t7e al:orit76 & Recover t7e deadlock <y a<ortin: t7e tran=action) A"ter =8cce=="8l co6;letion o" all t7e tran=action=- =y=te6 re;ort= t7e 8=er)

E4cl.(ion
&7ile e?ec8tin: t7e tran=action=- o8r =y=te6 doe= not acce;t any ot7er tran=action= "ro6 t7e 8=er) &e 7ave not i6;le6ented all t7e al:orit76= o" victi6 =election and deadlock recovery)

CSIT CO%%E!E C INC &AD) SYMCA (SCI* Se64III

Deadlock Detection & Recovery

5ea(i7ility St.dy

There are three types of Feasibility Study: !ec+nical 5ea(i7ility


T7e tec7niE8e i= 8=ed in de=i:nin: o" t7e =y=te6) T7e =y=te6 i= tec7nically "ea=i<le to 8=e) T7e =y=te6 i= 9ell =tr8ct8red and i= divided into vario8= 6od8le=) Any 8n9anted 6od8le can <e re6oved and ne9 6od8le can <e ea=ily added to t7e =y=te6) All di""erent 6od8le= are linked 9it7 eac7 Ot7er) T7e 6ain tec7nical reE8ire6ent o" t7e =y=te6 i= t7e O;eratin: Sy=te6 97ic7 i= already in=talled on t7e co6;8ter)

Econo&ical 5ea(i7ility
T7e ;a;er 9ork i= red8ced and al=o t7e data =tora:e co=t i= red8ced a= t7e data <ack8; o" t7e co6;lete =y=te6 can <e taken on J11 MB CD) So t7e ne9 =y=te6 i= econo6ically "ea=i<le to 8=e) A= =y=te6 i= "8lly a8to6atic it reE8ire= very le== ti6e "or entry o" t7e "8nction) Al=o t7e 8=er i= "a6iliar 9it7 t7e =y=te6) So t7ere i= no need to :ive t7e trainin: to t7e 8=er) T7e =tationary reE8ired "or t7e ;ro:ra6 i= le==) So t7e =y=te6 i= econo6ically "ea=i<le to 8=e)

O-erational 5ea(i7ility
T7e Sy=te6 i= o;erationally "ea=i<le to 8=e <eca8=e =y=te6 doe= not 7ave co6;le? a;;lication=) Si6;le LCMML codin: i= 8=ed in t7e =y=te6) )
CSIT CO%%E!E C INC &AD) SYMCA (SCI* Se64III 2

Deadlock Detection & Recovery

Sy(te& Re8.ire&ent(

Hard1are Re8.ire&ent(

Penti86 .MMD CPU or 6ore IBM 9ell46atc7ed 6ot7er<oard 0 !B 7ard di=k or 6ore Monoc7ro6e Monitor or 0/+ S#!A 6onitor

So0t1are Re8.ire&ent(
A;;lication@ T8r<o CMM O;eratin: Sy=te6@ MS4DOS- 9indo9 2FN2K or i:7er ver=ion=)

CSIT CO%%E!E C INC &AD) SYMCA (SCI* Se64III

01

Deadlock Detection & Recovery

Sy(te& Dia,ra&
Sy(te& 5lo1 Dia,ra&

Pro6;t

Acce;t $ile
$ile Not O;ened &rite To $ile

Error $o8nd

Scan
Error Detectio n

No Error No
I" Deadloc k Di=;lay %ock Ta<le <e"ore Relea=in: & a"ter Relea=in: %ock $or all Tran=8ction

Ye=
Di=;lay 'Deadlock Occo8red '

OO

Di=;lay %ock Ta<le& &ait "or !ra;7 <e"ore deadlock recovery

No

A A CSIT CO%%E!E C INC &AD) SYMCA (SCI* Se64III 00

Deadlock Detection & Recovery

A A Di=;lay %ock Ta<le & &ait "or :ra;7 a"ter deadlock recovery

Di=;lay %ock Ta<le <e"ore Relea=in: & a"ter Relea=in: %ock $or all Tran=action

Di=;lay 'All Tran=8ction co6;leted =8cce=="8lly+

CSIT CO%%E!E C INC &AD) SYMCA (SCI* Se64III

03

Deadlock Detection & Recovery

5.nctional Deco&-o(ition Dia,ra&

Main o;en Clo=e

Read
S7o9 Deadlock

Read %ock ta<le

S7o9 %ock ta<le

Relea=e %ock ta<le

C7eck %ock Ta<le

U;date %ock ta<le

Read !ra;7

=7o9 !ra;7

U;date !ra;7

C7eck !ra;7

5.nction( and Str.ct.re( 2(ed


CSIT CO%%E!E C INC &AD) SYMCA (SCI* Se64III 05

Deadlock Detection & Recovery

$la((
cla== &ait$or!ra;7 G ;rivate @ Declration o" varia<leP ;8<lic@ Me6<er $8nctionP HP Me6<er $8nction@ &ait$or!ra;7(*P void readC:ra;7(int*P void =7o9C:ra;7(*P void 8;dateC:ra;7(*P void c7eckCdeadlock(*P void =7o9Cdeadlock(*P

cla== %ockMana:er @ ;8<lic &ait$or!ra;7 G ;rivate @ Declration o" varia<leP ;8<lic @ Me6<er $8nctionP HP Me6<er $8nction@
CSIT CO%%E!E C INC &AD) SYMCA (SCI* Se64III 0/

Deadlock Detection & Recovery

void readClockCta<le(*P void =7o9ClockCta<le(*P void relea=eClock(c7ar "na6eQR*P int c7eckClockCrelea=e(c7ar "na6eQR*P void 8;dateClockCta<le(c7ar "na6eQR* cla== Tran=action$ile @ ;8<lic %ockMana:er G ;rivate @ DecPlaration o" varia<leP ;8<lic @ 6e6<er $8nctionP HP Me6<er $8nction@ void o;enC"ile(*P void readC"ile(*P void clo=eC"ile(*

O7/ect o0 created cla((


Tran=action$ile tP

CSIT CO%%E!E C INC &AD) SYMCA (SCI* Se64III

0F

Deadlock Detection & Recovery

Str.ct.re
=tr8ct %ockTa<le G Declaration o" varia<leP HP

In(tance 3aria7le
%ockTa<le ltQ011RP

INP2!9O2!P2!
CSIT CO%%E!E C INC &AD) SYMCA (SCI* Se64III 0I

Deadlock Detection & Recovery

Enter T7e Tran=actionS= $ile Na6e= @ (%e== T7an F Na6e=* @ a<c)t?t Error @ $ile Can Not O;ened))) Enter T7e Tran=actionS= $ile Na6e= @ (%e== T7an F Na6e=* @ t0)t?t t3)t?t Second Tran=action $ile Co6;leted))) Ta<le= Be"ore Relea=in: %ock=))) %ock Ta<le @ a < < c d t0)t?t 0 t3)t?t 3 t0)t?t 0 t3)t?t 3 t3)t?t 3 = ? = ? = T T $ T T

Ta<le= A"ter Relea=in: %ock=))) %ock Ta<le @ a


CSIT CO%%E!E C INC &AD) SYMCA (SCI* Se64III

t0)t?t 0

T
0J

Deadlock Detection & Recovery

< < c d

t3)t?t 3 t0)t?t 0 t3)t?t 3 t3)t?t 3

? = ? =

R T R R

$ir=t Tran=action $ile Co6;leted))) Ta<le= Be"ore Relea=in: %ock=))) %ock Ta<le @ a < < c d Ta<le= A"ter Relea=in: %ock=))) %ock Ta<le @ a < < c d t0)t?t 0 t3)t?t 3 t0)t?t 0 t3)t?t 3 t3)t?t 3 = ? = ? = R R R R R t0)t?t 0 t3)t?t 3 t0)t?t 0 t3)t?t 3 t3)t?t 3 = ? = ? = T R T R R

All Tran=action Are Co6;leted S8cce=="8lly)))

Enter T7e Tran=actionS= $ile Na6e= @ (%e== T7an F Na6e=* @ t5)t?t tF)t?t
CSIT CO%%E!E C INC &AD) SYMCA (SCI* Se64III 0K

Deadlock Detection & Recovery

Dead %ock Occ8red))) Ta<le= Be"ore Dead %ock Recovery))) %ock Ta<le @ a d c a c &ait4$or !ra;7 Ta<le @ 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 tF)t?t 3 tF)t?t 3 t5)t?t 0 t5)t?t 0 tF)t?t 3 ? ? = ? ? T T T $ $

Tran=action= in Dead %ock @ 3 0 1 1 1

Ta<le= A"ter Dead %ock Recovery))) %ock Ta<le @


CSIT CO%%E!E C INC &AD) SYMCA (SCI* Se64III 02

Deadlock Detection & Recovery

a d c a c &ait4$or !ra;7 Ta<le @ 1 1 1 1 1

tF)t?t 3 tF)t?t 3 t5)t?t 0 t5)t?t 0 tF)t?t 3

? ? = ? ?

R R T T R

1 1 1 1 1

1 1 1 1 1

1 1 1 1 1

1 1 1 1 1

Tran=action= in Dead %ock @ 1 1 1 1 1

$ir=t Tran=action $ile Co6;leted))) Ta<le= Be"ore Relea=in: %ock=)))


CSIT CO%%E!E C INC &AD) SYMCA (SCI* Se64III 31

Deadlock Detection & Recovery

%ock Ta<le @ a d c a c tF)t?t 3 tF)t?t 3 t5)t?t 0 t5)t?t 0 tF)t?t 3 ? ? = ? ? R R T T R

Ta<le= A"ter Relea=in: %ock=)))

%ock Ta<le @ a d c a c tF)t?t 3 tF)t?t 3 t5)t?t 0 t5)t?t 0 tF)t?t 3 ? ? = ? ? R R R R R

Second Tran=action $ile Co6;leted))) Ta<le= Be"ore Relea=in: %ock=)))

CSIT CO%%E!E C INC &AD) SYMCA (SCI* Se64III

30

Deadlock Detection & Recovery

%ock Ta<le @ a d c a c a d c Ta<le= A"ter Relea=in: %ock=))) %ock Ta<le @ a d c a c a d c tF)t?t 3 tF)t?t 3 t5)t?t 0 t5)t?t 0 tF)t?t 3 tF)t?t 3 tF)t?t 3 tF)t?t 3 ? ? = ? ? ? ? ? R R R R R R R R tF)t?t 3 tF)t?t 3 t5)t?t 0 t5)t?t 0 tF)t?t 3 tF)t?t 3 tF)t?t 3 tF)t?t 3 ? ? = ? ? ? ? ? R R R R R T T T

All Tran=action Are Co6;leted S8cce=="8lly)))

CSIT CO%%E!E C INC &AD) SYMCA (SCI* Se64III

33

Deadlock Detection & Recovery

$oncl.(ion

In o8r ;ro>ect 9e can ea=ily "ind 97et7er t7e deadlock i= occo8red or not-8=in: t7e 9ait "or :ra;7(directed :ra;7* ea=ily detect t7e deadlock and t7en recover t7e deadlock &di=;lay t7e 9ait "or :ra;7 ) Tran=action can <e 6ade in "e9 6in8te= ) J8=t =elect or "ill t7e reE8ired in"or6ation and =y=te6 9ill ;roce== it in "raction o" =econd and 6ay :ive= yo8 a;;ro;riate re=8lt= ) Sy=te6 ;rovide= 8=er "riendly "8nction= 97ic7 are very ea=y to o;erate ) O8r =o"t9are let= yo8 to co6;lete yo8r ta=k very "a=t and E8ick ) Re;ort= are :enerated E8ickly 9it7 a click o" =866ary o"

tran=action )

CSIT CO%%E!E C INC &AD) SYMCA (SCI* Se64III

35

Deadlock Detection & Recovery

52!2RE ENHAN$EMEN!

T7e =y=te6 =7o8ld acce;t t7e n n86<er o" tran=action= at any ti6e)

T7e =y=te6 =7o8ld c7eck all t7e =ynta?e=)

T7e =y=te6 =7o8ld con=ider t7e Co66it ;oint o" tran=action=)

T7e =y=te6 =7o8ld =7o9 :ra;7ical re;re=entation o" deadlock)

T7e =y=te6 =7o8ld recover a deadlock 8=in: all ;o==i<le al:orit76=)

CSIT CO%%E!E C INC &AD) SYMCA (SCI* Se64III

3/

Deadlock Detection & Recovery

)i7lio,ra-+y

0) Data<a=e Mana:e6ent Sy=te6 Ra:78 Ra6akri=7nan Jo7anne= !e7rke 3) Data<a=e Mana:e6ent Sy=te6 A<ra7a6 Sil<er=c7atA enry $ Tort7 5) O<>ect4Oriented Pro:ra66in: 9it7 CMM E Bala:8r8=a6y /) O<>ect4Oriented Modelin: and De=i:n Ja6e= Ra6<a8:7

CSIT CO%%E!E C INC &AD) SYMCA (SCI* Se64III

3F

Deadlock Detection & Recovery

CSIT CO%%E!E C INC &AD) SYMCA (SCI* Se64III

3I

Das könnte Ihnen auch gefallen