SlideShare une entreprise Scribd logo
1  sur  17
R.Pavithra,
II-MSc(IT),
Nadar saraswathi college of arts and science,
Theni.
CONCURRENCY CONTROL
CONTENTS
 What is concurrency control?
 Lock based protocol
 Two phase locking protocol
 deadlock
What is concurrency control?
 The technique is used to protect data when multiple users
are accessing same data concurrently(same time) is called
concurrency control.
Lock Based Protocol
o Lock is a mechanism to control concurrent access to data
item
o Data items can be locked in two modes:
a. Exclusive(X)Mode: Data item can be both read as well
as written. X-lock is request using lock-X instruction.
b. Shared (S) mode: data item can only be read,S-lock is
request using lock-s instruction.
o Lock request are made to concurrency-control manger.
o Transaction can proceed only after request s grated.
Cont……..
 Lock-compatibility matrix:
 A transaction may be granted a lock on
an item if the requested lock is
compatible with locks already held on
the item by other transaction.
 Any number of transaction can hold
shared locks on an item , but if any
transaction holds an exclusive on the
item no other transaction may hold any
lock on the item.
s x
s true
fals
e
x fals
e
fals
e
Cont……..
 A transaction may be granted a lock on an item if the
requested lock is compatible with locks already held
on the item by other transaction.
 Any number of transaction can hold shared locks on
an item , but if any transaction holds an exclusive on
the item no other transaction may hold any lock on
the item.
Cont…….
 If a lock cannot be granted , the requesting transaction is
made to wait till all incompatible locks held by other
transaction have been released. The lock is then granted.
 Example:
T1:lock-S(A); //Grant-S(A.T1)
read(A);
Unlock(A);
Lock-S(B); //Grant-S(B.T1)
Read(B);
Unlock(B);
Display(A+B)
Pitfalls of lock based protocol
 Locking as above is not sufficient to guarantee
serialializability- if A and B get in between the read of A and B
,the displayed sum would be wrong.
 A locking protocol is a set of rules followed by all transactions
while requesting and releasing locks . Locking protocols
restrict the set of possible schedules.
T3 T4
Lock-x(B)
Read(B)
B:=B – 50
Write(B)
Lock-X(A)
Lock-S(A)
Read(A)
Lock-S(B)
Cont….
 Neither T₃ nor T₄ can make progress –executing lock-S(B) causes T₄ to
wait for T₃ to release its lock on B , while executing lock-X(A) causes T₃
to wait for T₄ to relase its lock on A.
 To handle a deadlock one of T₃ or T₄ must be rolled back
and its locks relased.
 Starvation is also possible if concurrency control manager
is badly designed. For example:
I. A transaction may be waiting for an X –lock on an item
,while a sequence of other transactions request and are
granted an S-lock on the same item.
II. The same transaction is repeatedly rolled back due to
deadlocks.
 Concurrency control manager can be designed to prevent
starvation.
Two phase locking protocol
 This is a protocol which ensures conflict-serializable
schedules.
 Phase 1:Growing Phase
-transaction may obtain locks
-transaction may not release locks
 Phase 2: Shrinking Phase
-transaction may release locks
-transaction may not obtain locks
 The protocol assures serializability. It can be proved that
the transaction can be serialized in the order of their lock
points.
(i.e, the point where a transaction acquired its final lock).
Cont….
 Two –phase locking does not ensure from deadlocks.
 Cascading roll-back is possible under two-phase locking.
To avoid this, follow a modifed protocol called strict two-
phase locking. Here a transaction must hold all its
exclusive locks till it commits/aborts.
 Rigorous two-phase locking is even stricter: here all
locks are held till commit/abort. In this protocol
transaction can be serialized in the order in which they
commit.
DEADLOCK
 A set of process is deadlock if each process in the set is
waiting for an event that only another process in the set can
cause.
Four conditions for deadlock
 Mutual exclusive condition
-each resource assigned to 1 process or is available
 Hold and wait condition
-process holding resources can request additional
 No preeption condition
-previously granted resoures cannot forcibly taken away
 Circular wait condition
-must be a circular chain of 2 or more process
-each is waiting for resource held by next member of the
chain
Strategies of deadlock handling
 Deadlock prevention:
prevents deadlocks by restraining requests made to ensure
that at least one of the deadlock conditions cannot occur.
• Deadlock avoidance:
Dynamically grants a resource to a process if the resulting
state is safe. A state is safe if there is at least one execution
sequence that allows all process to run to completion.
• Deadlock detection and recovery:
That allows dealocks to form; then finds and breaks them.
Deadlock avoidance
 WAIT- DIE RULE:
if Tᵢ request a lock on a data
item which is already locked
by Tʲ, then Tᵢ is permitted to
wait if ts (Tᵢ)<ts(Tʲ). If ts
(Tᵢ)>ts(Tʲ), then Tᵢ is aborted
and restarted with the same time
stamp.
-if ts (Tᵢ)<ts(Tʲ) then Tᵢ waits
else Tᵢ dies
-non-preempting: Tᵢ never
preempts Tʲ
-prefers younger transactions
 WOUND-WAIT RULE:
If Tᵢ request a lock on a data
item which is already locked by
Tʲ, then Tᵢ is permitted to wait if
ts (Tᵢ)>ts(Tʲ). If ts (Tᵢ)<ts(Tʲ),
then Tʲ is aborted and the lock is
granted to Tᵢ.
-if ts (Tᵢ)<ts(Tʲ) then Tʲ is
wounded else Tᵢ waits
- preemptive : Tᵢ preempts Tʲ if it
is younger
-prefers older transactions
Deadlock detection
For deadlock detection, the system must provide:
 An algorithm that examines the state of the system to detect
whether a deadlock has occurred
 And an algorithm to recover from the deadlock
A detection-and –recovery scheme require various kinds of
overhead
 Runtime –time costs of maintaining necessary information and
executing the detection algorithm.
concurrency control

Contenu connexe

Tendances

Deadlock Detection
Deadlock DetectionDeadlock Detection
Deadlock DetectionStuart Joy
 
Concurrency Control Techniques
Concurrency Control TechniquesConcurrency Control Techniques
Concurrency Control TechniquesRaj vardhan
 
Concurrency control
Concurrency controlConcurrency control
Concurrency controlvarsha singh
 
Dbms ii mca-ch10-concurrency-control-2013
Dbms ii mca-ch10-concurrency-control-2013Dbms ii mca-ch10-concurrency-control-2013
Dbms ii mca-ch10-concurrency-control-2013Prosanta Ghosh
 
Concurrency Control in Database Management System
Concurrency Control in Database Management SystemConcurrency Control in Database Management System
Concurrency Control in Database Management SystemJanki Shah
 
Deadlock management
Deadlock managementDeadlock management
Deadlock managementAhmed kasim
 
Concurrency control
Concurrency controlConcurrency control
Concurrency controlJaya Jeswani
 
Timestamp based protocol
Timestamp based protocolTimestamp based protocol
Timestamp based protocolVincent Chu
 
Database ,11 Concurrency Control
Database ,11 Concurrency ControlDatabase ,11 Concurrency Control
Database ,11 Concurrency ControlAli Usman
 
Lock Interface in Java
Lock Interface in JavaLock Interface in Java
Lock Interface in JavaHome
 
Java reentrant lock tutorial by jeetendra mandal
Java reentrant lock tutorial by jeetendra mandalJava reentrant lock tutorial by jeetendra mandal
Java reentrant lock tutorial by jeetendra mandaljeetendra mandal
 
Sequence detector for "111"
Sequence detector for "111"Sequence detector for "111"
Sequence detector for "111"Omkar Rane
 

Tendances (20)

Deadlock Detection
Deadlock DetectionDeadlock Detection
Deadlock Detection
 
Concurrency Control Techniques
Concurrency Control TechniquesConcurrency Control Techniques
Concurrency Control Techniques
 
Concurrency control
Concurrency controlConcurrency control
Concurrency control
 
Concurrency control
Concurrency controlConcurrency control
Concurrency control
 
Cs501 concurrency
Cs501 concurrencyCs501 concurrency
Cs501 concurrency
 
Dbms ii mca-ch10-concurrency-control-2013
Dbms ii mca-ch10-concurrency-control-2013Dbms ii mca-ch10-concurrency-control-2013
Dbms ii mca-ch10-concurrency-control-2013
 
Concurrency Control in Database Management System
Concurrency Control in Database Management SystemConcurrency Control in Database Management System
Concurrency Control in Database Management System
 
2 phase locking protocol DBMS
2 phase locking protocol DBMS2 phase locking protocol DBMS
2 phase locking protocol DBMS
 
Unit 6
Unit 6Unit 6
Unit 6
 
concurrency-control
concurrency-controlconcurrency-control
concurrency-control
 
Deadlock dbms
Deadlock dbmsDeadlock dbms
Deadlock dbms
 
Deadlock in dbms
Deadlock in dbmsDeadlock in dbms
Deadlock in dbms
 
Deadlock management
Deadlock managementDeadlock management
Deadlock management
 
Concurrency control
Concurrency controlConcurrency control
Concurrency control
 
Deadlock in database
Deadlock in databaseDeadlock in database
Deadlock in database
 
Timestamp based protocol
Timestamp based protocolTimestamp based protocol
Timestamp based protocol
 
Database ,11 Concurrency Control
Database ,11 Concurrency ControlDatabase ,11 Concurrency Control
Database ,11 Concurrency Control
 
Lock Interface in Java
Lock Interface in JavaLock Interface in Java
Lock Interface in Java
 
Java reentrant lock tutorial by jeetendra mandal
Java reentrant lock tutorial by jeetendra mandalJava reentrant lock tutorial by jeetendra mandal
Java reentrant lock tutorial by jeetendra mandal
 
Sequence detector for "111"
Sequence detector for "111"Sequence detector for "111"
Sequence detector for "111"
 

Similaire à concurrency control

Concurrency Control & Deadlock Handling
Concurrency Control & Deadlock HandlingConcurrency Control & Deadlock Handling
Concurrency Control & Deadlock HandlingMeghaj Mallick
 
Concurrency Control.pptx
Concurrency Control.pptxConcurrency Control.pptx
Concurrency Control.pptxVijaySourtha
 
DBMS Presentation.pptx
DBMS Presentation.pptxDBMS Presentation.pptx
DBMS Presentation.pptxPravinBhargav1
 
Unit 5 rdbms study_material
Unit 5  rdbms study_materialUnit 5  rdbms study_material
Unit 5 rdbms study_materialgayaramesh
 
Concurrency Control, Recovery, Case Studies
Concurrency Control, Recovery, Case StudiesConcurrency Control, Recovery, Case Studies
Concurrency Control, Recovery, Case StudiesPrabu U
 
db unit 4 dbms protocols in transaction
db unit 4 dbms  protocols in transactiondb unit 4 dbms  protocols in transaction
db unit 4 dbms protocols in transactionKumari Naveen
 
Concurrency control
Concurrency  controlConcurrency  control
Concurrency controlJaved Khan
 
Unit 4 Concurrency control.pptx dbms lovely
Unit 4 Concurrency control.pptx dbms lovelyUnit 4 Concurrency control.pptx dbms lovely
Unit 4 Concurrency control.pptx dbms lovelyPritishMajumdar3
 
Unit 4 Concurrency control.pptx dbms lovely
Unit 4 Concurrency control.pptx dbms lovelyUnit 4 Concurrency control.pptx dbms lovely
Unit 4 Concurrency control.pptx dbms lovelyPritishMajumdar3
 
deadlock and locking - dbms
deadlock and locking -  dbmsdeadlock and locking -  dbms
deadlock and locking - dbmsSurya Swaroop
 
Design & Development of an Advanced Database Management System Using Multiver...
Design & Development of an Advanced Database Management System Using Multiver...Design & Development of an Advanced Database Management System Using Multiver...
Design & Development of an Advanced Database Management System Using Multiver...IOSR Journals
 
concurrencycontrol from power pint pdf a
concurrencycontrol  from power pint pdf aconcurrencycontrol  from power pint pdf a
concurrencycontrol from power pint pdf aMdAyanParwez
 

Similaire à concurrency control (20)

Concurrency Control & Deadlock Handling
Concurrency Control & Deadlock HandlingConcurrency Control & Deadlock Handling
Concurrency Control & Deadlock Handling
 
Ch16
Ch16Ch16
Ch16
 
Concurrency Control.pptx
Concurrency Control.pptxConcurrency Control.pptx
Concurrency Control.pptx
 
DBMS Presentation.pptx
DBMS Presentation.pptxDBMS Presentation.pptx
DBMS Presentation.pptx
 
Unit 5 rdbms study_material
Unit 5  rdbms study_materialUnit 5  rdbms study_material
Unit 5 rdbms study_material
 
Chapter18
Chapter18Chapter18
Chapter18
 
Concurrency Control, Recovery, Case Studies
Concurrency Control, Recovery, Case StudiesConcurrency Control, Recovery, Case Studies
Concurrency Control, Recovery, Case Studies
 
Dbms
DbmsDbms
Dbms
 
2 con control
2 con control2 con control
2 con control
 
UNIT II.pptx
UNIT II.pptxUNIT II.pptx
UNIT II.pptx
 
db unit 4 dbms protocols in transaction
db unit 4 dbms  protocols in transactiondb unit 4 dbms  protocols in transaction
db unit 4 dbms protocols in transaction
 
Concurrency control
Concurrency  controlConcurrency  control
Concurrency control
 
Unit 4 Concurrency control.pptx dbms lovely
Unit 4 Concurrency control.pptx dbms lovelyUnit 4 Concurrency control.pptx dbms lovely
Unit 4 Concurrency control.pptx dbms lovely
 
Unit 4 Concurrency control.pptx dbms lovely
Unit 4 Concurrency control.pptx dbms lovelyUnit 4 Concurrency control.pptx dbms lovely
Unit 4 Concurrency control.pptx dbms lovely
 
deadlock and locking - dbms
deadlock and locking -  dbmsdeadlock and locking -  dbms
deadlock and locking - dbms
 
Concurrency control
Concurrency controlConcurrency control
Concurrency control
 
F017213747
F017213747F017213747
F017213747
 
F017213747
F017213747F017213747
F017213747
 
Design & Development of an Advanced Database Management System Using Multiver...
Design & Development of an Advanced Database Management System Using Multiver...Design & Development of an Advanced Database Management System Using Multiver...
Design & Development of an Advanced Database Management System Using Multiver...
 
concurrencycontrol from power pint pdf a
concurrencycontrol  from power pint pdf aconcurrencycontrol  from power pint pdf a
concurrencycontrol from power pint pdf a
 

Plus de rajshreemuthiah (20)

oracle
oracleoracle
oracle
 
quality
qualityquality
quality
 
bigdata
bigdatabigdata
bigdata
 
polymorphism
polymorphismpolymorphism
polymorphism
 
solutions and understanding text analytics
solutions and understanding text analyticssolutions and understanding text analytics
solutions and understanding text analytics
 
interface
interfaceinterface
interface
 
Testing &ampdebugging
Testing &ampdebuggingTesting &ampdebugging
Testing &ampdebugging
 
Education
EducationEducation
Education
 
Formal verification
Formal verificationFormal verification
Formal verification
 
Transaction management
Transaction management Transaction management
Transaction management
 
Multi thread
Multi threadMulti thread
Multi thread
 
System testing
System testingSystem testing
System testing
 
software maintenance
software maintenancesoftware maintenance
software maintenance
 
exception handling
exception handlingexception handling
exception handling
 
e governance
e governancee governance
e governance
 
recovery management
recovery managementrecovery management
recovery management
 
Implementing polymorphism
Implementing polymorphismImplementing polymorphism
Implementing polymorphism
 
Buffer managements
Buffer managementsBuffer managements
Buffer managements
 
os linux
os linuxos linux
os linux
 
Ipv4
Ipv4Ipv4
Ipv4
 

Dernier

Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 

Dernier (20)

Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 

concurrency control

  • 1. R.Pavithra, II-MSc(IT), Nadar saraswathi college of arts and science, Theni. CONCURRENCY CONTROL
  • 2. CONTENTS  What is concurrency control?  Lock based protocol  Two phase locking protocol  deadlock
  • 3. What is concurrency control?  The technique is used to protect data when multiple users are accessing same data concurrently(same time) is called concurrency control.
  • 4. Lock Based Protocol o Lock is a mechanism to control concurrent access to data item o Data items can be locked in two modes: a. Exclusive(X)Mode: Data item can be both read as well as written. X-lock is request using lock-X instruction. b. Shared (S) mode: data item can only be read,S-lock is request using lock-s instruction. o Lock request are made to concurrency-control manger. o Transaction can proceed only after request s grated.
  • 5. Cont……..  Lock-compatibility matrix:  A transaction may be granted a lock on an item if the requested lock is compatible with locks already held on the item by other transaction.  Any number of transaction can hold shared locks on an item , but if any transaction holds an exclusive on the item no other transaction may hold any lock on the item. s x s true fals e x fals e fals e
  • 6. Cont……..  A transaction may be granted a lock on an item if the requested lock is compatible with locks already held on the item by other transaction.  Any number of transaction can hold shared locks on an item , but if any transaction holds an exclusive on the item no other transaction may hold any lock on the item.
  • 7. Cont…….  If a lock cannot be granted , the requesting transaction is made to wait till all incompatible locks held by other transaction have been released. The lock is then granted.  Example: T1:lock-S(A); //Grant-S(A.T1) read(A); Unlock(A); Lock-S(B); //Grant-S(B.T1) Read(B); Unlock(B); Display(A+B)
  • 8. Pitfalls of lock based protocol  Locking as above is not sufficient to guarantee serialializability- if A and B get in between the read of A and B ,the displayed sum would be wrong.  A locking protocol is a set of rules followed by all transactions while requesting and releasing locks . Locking protocols restrict the set of possible schedules. T3 T4 Lock-x(B) Read(B) B:=B – 50 Write(B) Lock-X(A) Lock-S(A) Read(A) Lock-S(B)
  • 9. Cont….  Neither T₃ nor T₄ can make progress –executing lock-S(B) causes T₄ to wait for T₃ to release its lock on B , while executing lock-X(A) causes T₃ to wait for T₄ to relase its lock on A.  To handle a deadlock one of T₃ or T₄ must be rolled back and its locks relased.  Starvation is also possible if concurrency control manager is badly designed. For example: I. A transaction may be waiting for an X –lock on an item ,while a sequence of other transactions request and are granted an S-lock on the same item. II. The same transaction is repeatedly rolled back due to deadlocks.  Concurrency control manager can be designed to prevent starvation.
  • 10. Two phase locking protocol  This is a protocol which ensures conflict-serializable schedules.  Phase 1:Growing Phase -transaction may obtain locks -transaction may not release locks  Phase 2: Shrinking Phase -transaction may release locks -transaction may not obtain locks  The protocol assures serializability. It can be proved that the transaction can be serialized in the order of their lock points. (i.e, the point where a transaction acquired its final lock).
  • 11. Cont….  Two –phase locking does not ensure from deadlocks.  Cascading roll-back is possible under two-phase locking. To avoid this, follow a modifed protocol called strict two- phase locking. Here a transaction must hold all its exclusive locks till it commits/aborts.  Rigorous two-phase locking is even stricter: here all locks are held till commit/abort. In this protocol transaction can be serialized in the order in which they commit.
  • 12. DEADLOCK  A set of process is deadlock if each process in the set is waiting for an event that only another process in the set can cause.
  • 13. Four conditions for deadlock  Mutual exclusive condition -each resource assigned to 1 process or is available  Hold and wait condition -process holding resources can request additional  No preeption condition -previously granted resoures cannot forcibly taken away  Circular wait condition -must be a circular chain of 2 or more process -each is waiting for resource held by next member of the chain
  • 14. Strategies of deadlock handling  Deadlock prevention: prevents deadlocks by restraining requests made to ensure that at least one of the deadlock conditions cannot occur. • Deadlock avoidance: Dynamically grants a resource to a process if the resulting state is safe. A state is safe if there is at least one execution sequence that allows all process to run to completion. • Deadlock detection and recovery: That allows dealocks to form; then finds and breaks them.
  • 15. Deadlock avoidance  WAIT- DIE RULE: if Tᵢ request a lock on a data item which is already locked by Tʲ, then Tᵢ is permitted to wait if ts (Tᵢ)<ts(Tʲ). If ts (Tᵢ)>ts(Tʲ), then Tᵢ is aborted and restarted with the same time stamp. -if ts (Tᵢ)<ts(Tʲ) then Tᵢ waits else Tᵢ dies -non-preempting: Tᵢ never preempts Tʲ -prefers younger transactions  WOUND-WAIT RULE: If Tᵢ request a lock on a data item which is already locked by Tʲ, then Tᵢ is permitted to wait if ts (Tᵢ)>ts(Tʲ). If ts (Tᵢ)<ts(Tʲ), then Tʲ is aborted and the lock is granted to Tᵢ. -if ts (Tᵢ)<ts(Tʲ) then Tʲ is wounded else Tᵢ waits - preemptive : Tᵢ preempts Tʲ if it is younger -prefers older transactions
  • 16. Deadlock detection For deadlock detection, the system must provide:  An algorithm that examines the state of the system to detect whether a deadlock has occurred  And an algorithm to recover from the deadlock A detection-and –recovery scheme require various kinds of overhead  Runtime –time costs of maintaining necessary information and executing the detection algorithm.