SlideShare a Scribd company logo
1 of 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

More Related Content

What's hot

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
 

What's hot (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"
 

Similar to 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
 

Similar to 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
 

More from 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
 

Recently uploaded

SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 

Recently uploaded (20)

DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 

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.