SlideShare ist ein Scribd-Unternehmen logo
1 von 12
DATABASE MANAGEMENT
SYSTEM:
T WO PHASE LOCKING PROTOCOL
1 7 0 4 1 0 1 0 7 0 2 7
D H A N A N J AY S I N H J H A L A
S Y C E - I B AT C H B
INDEX
• Locks
• Locking protocols
• 2 phase locking protocol
–Phases
–Merits
–demerits
LOCKS
To ensure serializability, it is required that data items should be
accessed in mutual exclusive manner, i.e. if one transaction is accessing
a data item, no other transaction can modify that data item.
To implement this requirement locks are used.
A transaction is allowed to access a data item only if it is currently
holding a lock on that item.
There are 2 modes in which a data item may be locked:
Shared mode: if a transaction T1 has obtained a shared mode lock on
item Q, then T1 can read, but cannot write Q. it is denoted by S.
Exclusive: if a transaction T1 has obtained a exclusive mode lock on
item Q, then T1 can read & also write Q. it is denoted by X.
LOCKING PROTOCOLS
When a transaction requests a lock on a data item in a particular mode
and no other transaction has a lock on the same data item, the lock can
be granted.
Supposing a transaction T1 requests a lock on data item Q in a particular
mode M, the concurrency control manager grants the lock provided that
There is no other transaction holding a lock on Q in a mode that
conflicts with M
There is no other transaction that is waiting for a lock on Q, and that
made its lock request before T1.
2 PHASE LOCKING PROTOCOL
• This protocol requires that each transaction issue lock and
unlock requests in two phases:
– Growing phase: in this phase, a transaction may obtain locks, but
may not release any lock.
– Shrinking phase: in this phase, a transaction may release locks, but
may not obtain any new locks.
– Initially, a transaction is in the growing phase. The transaction
acquires locks as needed. Once a transaction releases a lock, it enters
in the shrinking phase and it cannot issue more lock requests.
2 PHASE LOCKING PROTOCOL
• E.g. Transaction given below is a two phase transaction.
• T3:
– lock X(B);
– read(B);
– B:= B-50;
– write(B);
– lock X(A);
– read(A);
– A:=A+50;
– write(A);
– unlock(B);
– unlock(A);
MERITS OF 2 PHASE LOCKING PROTOCOL
• The two phase locking protocol ensure conflict serializability.
• Consider any transaction, the point in the schedule where the
transaction has obtained it's final lock is called the lock point
of the transaction.
• Now, transaction can be ordered according to their lock
points. This ordering is a serializability ordering for the
transactions.
DEMERITS OF 2 PHASE LOCKING PROTOCOL
• The two phase locking protocol Does not ensure freedom from
deadlock:
– Consider the schedule shown in figure
– Transaction T3 and T4 are two phases but they are deadlocked.
• Cascading rollback may occur under two phase locking:
– Consider the schedule shown in figure
• As shown in the above figure transactions T5,T6 and T7 are
two phase, but failure of T5 after the read(A) instruction of T7
leads to cascading rollback of T6 and T7.
• Cascading rollback can be avoided by modification of two
phase locking:
– 1. Strict two phase locking protocol: This protocol requires that
locking should be two phase and all executive mode locks taken by a
transaction should be held until the transaction commits. This
requirement prevents any transaction from reading the data written
by any uncommitted transaction under exclusive mode until the
transaction commits.
• 2. The rigorous two phase locking protocol: This protocol
requires that all locks be held until the transaction commits.
2 phase locking protocol DBMS

Weitere ähnliche Inhalte

Was ist angesagt?

13. Query Processing in DBMS
13. Query Processing in DBMS13. Query Processing in DBMS
13. Query Processing in DBMSkoolkampus
 
Relational Data Model Introduction
Relational Data Model IntroductionRelational Data Model Introduction
Relational Data Model IntroductionNishant Munjal
 
linked list in data structure
linked list in data structure linked list in data structure
linked list in data structure shameen khan
 
Query processing and optimization (updated)
Query processing and optimization (updated)Query processing and optimization (updated)
Query processing and optimization (updated)Ravinder Kamboj
 
Transactions in dbms
Transactions in dbmsTransactions in dbms
Transactions in dbmsNancy Gulati
 
17. Recovery System in DBMS
17. Recovery System in DBMS17. Recovery System in DBMS
17. Recovery System in DBMSkoolkampus
 
Concurrent transactions
Concurrent transactionsConcurrent transactions
Concurrent transactionsSajan Sahu
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity Constraintsmadhav bansal
 
Concurrency Control Techniques
Concurrency Control TechniquesConcurrency Control Techniques
Concurrency Control TechniquesRaj vardhan
 
1.4 data independence
1.4 data independence1.4 data independence
1.4 data independenceBHARATH KUMAR
 
Concurrency Control in Distributed Database.
Concurrency Control in Distributed Database.Concurrency Control in Distributed Database.
Concurrency Control in Distributed Database.Meghaj Mallick
 

Was ist angesagt? (20)

13. Query Processing in DBMS
13. Query Processing in DBMS13. Query Processing in DBMS
13. Query Processing in DBMS
 
Relational Data Model Introduction
Relational Data Model IntroductionRelational Data Model Introduction
Relational Data Model Introduction
 
linked list in data structure
linked list in data structure linked list in data structure
linked list in data structure
 
Concurrency control
Concurrency controlConcurrency control
Concurrency control
 
Query processing and optimization (updated)
Query processing and optimization (updated)Query processing and optimization (updated)
Query processing and optimization (updated)
 
Timestamp protocols
Timestamp protocolsTimestamp protocols
Timestamp protocols
 
Transactions in dbms
Transactions in dbmsTransactions in dbms
Transactions in dbms
 
17. Recovery System in DBMS
17. Recovery System in DBMS17. Recovery System in DBMS
17. Recovery System in DBMS
 
Concurrent transactions
Concurrent transactionsConcurrent transactions
Concurrent transactions
 
DBMS: Types of keys
DBMS:  Types of keysDBMS:  Types of keys
DBMS: Types of keys
 
Serializability
SerializabilitySerializability
Serializability
 
Query processing
Query processingQuery processing
Query processing
 
DBMS Keys
DBMS KeysDBMS Keys
DBMS Keys
 
Database recovery
Database recoveryDatabase recovery
Database recovery
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity Constraints
 
Concurrency Control Techniques
Concurrency Control TechniquesConcurrency Control Techniques
Concurrency Control Techniques
 
1.4 data independence
1.4 data independence1.4 data independence
1.4 data independence
 
Type Checking(Compiler Design) #ShareThisIfYouLike
Type Checking(Compiler Design) #ShareThisIfYouLikeType Checking(Compiler Design) #ShareThisIfYouLike
Type Checking(Compiler Design) #ShareThisIfYouLike
 
Concurrency Control in Distributed Database.
Concurrency Control in Distributed Database.Concurrency Control in Distributed Database.
Concurrency Control in Distributed Database.
 
Query processing
Query processingQuery processing
Query processing
 

Ähnlich wie 2 phase locking protocol DBMS

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
 
Concurrency Management
Concurrency ManagementConcurrency Management
Concurrency ManagementSURBHI SAROHA
 
Concurrency control
Concurrency controlConcurrency control
Concurrency controlJaya Jeswani
 
DBMS Presentation.pptx
DBMS Presentation.pptxDBMS Presentation.pptx
DBMS Presentation.pptxPravinBhargav1
 
concurrencycontrol from power pint pdf a
concurrencycontrol  from power pint pdf aconcurrencycontrol  from power pint pdf a
concurrencycontrol from power pint pdf aMdAyanParwez
 
Concurrency Control, Recovery, Case Studies
Concurrency Control, Recovery, Case StudiesConcurrency Control, Recovery, Case Studies
Concurrency Control, Recovery, Case StudiesPrabu U
 
Variations Of Two Phase Locking
Variations Of Two Phase LockingVariations Of Two Phase Locking
Variations Of Two Phase LockingMohammed Twaha
 
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 note.pdf
Concurrency note.pdfConcurrency note.pdf
Concurrency note.pdfBijayNag1
 
Concurrency Control.pptx
Concurrency Control.pptxConcurrency Control.pptx
Concurrency Control.pptxVijaySourtha
 
recoverability and serializability dbms
recoverability and serializability  dbmsrecoverability and serializability  dbms
recoverability and serializability dbmsKumari Naveen
 

Ähnlich wie 2 phase locking protocol DBMS (20)

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
 
Concurrency Management
Concurrency ManagementConcurrency Management
Concurrency Management
 
Concurrency control
Concurrency controlConcurrency control
Concurrency control
 
UNIT II.pptx
UNIT II.pptxUNIT II.pptx
UNIT II.pptx
 
DBMS Presentation.pptx
DBMS Presentation.pptxDBMS Presentation.pptx
DBMS Presentation.pptx
 
concurrency-control
concurrency-controlconcurrency-control
concurrency-control
 
Cs501 concurrency
Cs501 concurrencyCs501 concurrency
Cs501 concurrency
 
concurrencycontrol from power pint pdf a
concurrencycontrol  from power pint pdf aconcurrencycontrol  from power pint pdf a
concurrencycontrol from power pint pdf a
 
Unit 5 dbms
Unit 5 dbmsUnit 5 dbms
Unit 5 dbms
 
Dbms
DbmsDbms
Dbms
 
Concurrency Control, Recovery, Case Studies
Concurrency Control, Recovery, Case StudiesConcurrency Control, Recovery, Case Studies
Concurrency Control, Recovery, Case Studies
 
concurrency control
concurrency controlconcurrency control
concurrency control
 
Variations Of Two Phase Locking
Variations Of Two Phase LockingVariations Of Two Phase Locking
Variations Of Two Phase Locking
 
Concurrency control
Concurrency control Concurrency control
Concurrency control
 
Concurrency Control
Concurrency ControlConcurrency Control
Concurrency Control
 
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 note.pdf
Concurrency note.pdfConcurrency note.pdf
Concurrency note.pdf
 
Concurrency Control.pptx
Concurrency Control.pptxConcurrency Control.pptx
Concurrency Control.pptx
 
recoverability and serializability dbms
recoverability and serializability  dbmsrecoverability and serializability  dbms
recoverability and serializability dbms
 

Mehr von Dhananjaysinh Jhala

JavaScript own objects(Web Technology)
JavaScript own objects(Web Technology)JavaScript own objects(Web Technology)
JavaScript own objects(Web Technology)Dhananjaysinh Jhala
 
Coding standard and coding guideline
Coding standard and coding guidelineCoding standard and coding guideline
Coding standard and coding guidelineDhananjaysinh Jhala
 
BCD arithmetic and 16-bit data operations
BCD arithmetic and 16-bit data operationsBCD arithmetic and 16-bit data operations
BCD arithmetic and 16-bit data operationsDhananjaysinh Jhala
 
applications of first order non linear partial differential equation
applications of first order non linear partial differential equationapplications of first order non linear partial differential equation
applications of first order non linear partial differential equationDhananjaysinh Jhala
 
variable entered map digital electronics
variable entered map digital electronicsvariable entered map digital electronics
variable entered map digital electronicsDhananjaysinh Jhala
 
Parabola, hyperbola and its applications
Parabola, hyperbola and its applicationsParabola, hyperbola and its applications
Parabola, hyperbola and its applicationsDhananjaysinh Jhala
 
1st, 2nd kind improper integrals
1st, 2nd kind improper integrals 1st, 2nd kind improper integrals
1st, 2nd kind improper integrals Dhananjaysinh Jhala
 
Earthing, grounding and isolation
Earthing, grounding and isolation Earthing, grounding and isolation
Earthing, grounding and isolation Dhananjaysinh Jhala
 

Mehr von Dhananjaysinh Jhala (20)

Food donation project report II
Food donation project report IIFood donation project report II
Food donation project report II
 
Food donation project report I
Food donation project report IFood donation project report I
Food donation project report I
 
JavaScript own objects(Web Technology)
JavaScript own objects(Web Technology)JavaScript own objects(Web Technology)
JavaScript own objects(Web Technology)
 
Coding standard and coding guideline
Coding standard and coding guidelineCoding standard and coding guideline
Coding standard and coding guideline
 
BCD arithmetic and 16-bit data operations
BCD arithmetic and 16-bit data operationsBCD arithmetic and 16-bit data operations
BCD arithmetic and 16-bit data operations
 
Design of a two pass assembler
Design of a two pass assemblerDesign of a two pass assembler
Design of a two pass assembler
 
Binary search trees
Binary search treesBinary search trees
Binary search trees
 
Sleeping barber problem
Sleeping barber problemSleeping barber problem
Sleeping barber problem
 
Email and DNS
Email and DNSEmail and DNS
Email and DNS
 
Friend function OOPC
Friend function OOPCFriend function OOPC
Friend function OOPC
 
applications of first order non linear partial differential equation
applications of first order non linear partial differential equationapplications of first order non linear partial differential equation
applications of first order non linear partial differential equation
 
concepts of national income
concepts of national income concepts of national income
concepts of national income
 
Circular Queue data structure
Circular Queue data structureCircular Queue data structure
Circular Queue data structure
 
variable entered map digital electronics
variable entered map digital electronicsvariable entered map digital electronics
variable entered map digital electronics
 
Dark sensor using photodiode
Dark sensor using photodiodeDark sensor using photodiode
Dark sensor using photodiode
 
Parabola, hyperbola and its applications
Parabola, hyperbola and its applicationsParabola, hyperbola and its applications
Parabola, hyperbola and its applications
 
1st, 2nd kind improper integrals
1st, 2nd kind improper integrals 1st, 2nd kind improper integrals
1st, 2nd kind improper integrals
 
Corporate life and skills
Corporate life and skillsCorporate life and skills
Corporate life and skills
 
type1,2 superconductors
type1,2 superconductors type1,2 superconductors
type1,2 superconductors
 
Earthing, grounding and isolation
Earthing, grounding and isolation Earthing, grounding and isolation
Earthing, grounding and isolation
 

Kürzlich hochgeladen

Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catcherssdickerson1
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...121011101441
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEroselinkalist12
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleAlluxio, Inc.
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitterShivangiSharma879191
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 

Kürzlich hochgeladen (20)

Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at Scale
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 

2 phase locking protocol DBMS

  • 1. DATABASE MANAGEMENT SYSTEM: T WO PHASE LOCKING PROTOCOL 1 7 0 4 1 0 1 0 7 0 2 7 D H A N A N J AY S I N H J H A L A S Y C E - I B AT C H B
  • 2. INDEX • Locks • Locking protocols • 2 phase locking protocol –Phases –Merits –demerits
  • 3. LOCKS To ensure serializability, it is required that data items should be accessed in mutual exclusive manner, i.e. if one transaction is accessing a data item, no other transaction can modify that data item. To implement this requirement locks are used. A transaction is allowed to access a data item only if it is currently holding a lock on that item. There are 2 modes in which a data item may be locked: Shared mode: if a transaction T1 has obtained a shared mode lock on item Q, then T1 can read, but cannot write Q. it is denoted by S. Exclusive: if a transaction T1 has obtained a exclusive mode lock on item Q, then T1 can read & also write Q. it is denoted by X.
  • 4. LOCKING PROTOCOLS When a transaction requests a lock on a data item in a particular mode and no other transaction has a lock on the same data item, the lock can be granted. Supposing a transaction T1 requests a lock on data item Q in a particular mode M, the concurrency control manager grants the lock provided that There is no other transaction holding a lock on Q in a mode that conflicts with M There is no other transaction that is waiting for a lock on Q, and that made its lock request before T1.
  • 5. 2 PHASE LOCKING PROTOCOL • This protocol requires that each transaction issue lock and unlock requests in two phases: – Growing phase: in this phase, a transaction may obtain locks, but may not release any lock. – Shrinking phase: in this phase, a transaction may release locks, but may not obtain any new locks. – Initially, a transaction is in the growing phase. The transaction acquires locks as needed. Once a transaction releases a lock, it enters in the shrinking phase and it cannot issue more lock requests.
  • 6. 2 PHASE LOCKING PROTOCOL • E.g. Transaction given below is a two phase transaction. • T3: – lock X(B); – read(B); – B:= B-50; – write(B); – lock X(A); – read(A); – A:=A+50; – write(A); – unlock(B); – unlock(A);
  • 7. MERITS OF 2 PHASE LOCKING PROTOCOL • The two phase locking protocol ensure conflict serializability. • Consider any transaction, the point in the schedule where the transaction has obtained it's final lock is called the lock point of the transaction. • Now, transaction can be ordered according to their lock points. This ordering is a serializability ordering for the transactions.
  • 8. DEMERITS OF 2 PHASE LOCKING PROTOCOL • The two phase locking protocol Does not ensure freedom from deadlock: – Consider the schedule shown in figure – Transaction T3 and T4 are two phases but they are deadlocked.
  • 9. • Cascading rollback may occur under two phase locking: – Consider the schedule shown in figure
  • 10. • As shown in the above figure transactions T5,T6 and T7 are two phase, but failure of T5 after the read(A) instruction of T7 leads to cascading rollback of T6 and T7. • Cascading rollback can be avoided by modification of two phase locking: – 1. Strict two phase locking protocol: This protocol requires that locking should be two phase and all executive mode locks taken by a transaction should be held until the transaction commits. This requirement prevents any transaction from reading the data written by any uncommitted transaction under exclusive mode until the transaction commits.
  • 11. • 2. The rigorous two phase locking protocol: This protocol requires that all locks be held until the transaction commits.