0% found this document useful (0 votes)
8 views18 pages

DBMS

Uploaded by

pk9690123472
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views18 pages

DBMS

Uploaded by

pk9690123472
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 18

APEX INSTITUTE OF TECHNOLOGY

DBMS PRESENTATION
Topic :- Lock Based Protocol for Concurrency
Control
-presented by Ravinder Gangwar and Pawan Kumar
ODUCTION
E
yansaction TOPICS COVERED
ve D
oncurrency
ques
C IN THIS
B PRESENTATION
A
INTRODUCTION

• Concurrency control manages


simultaneous operations without
them conflicting with each other.
• It’s provides a procedure that is
able to control concurrent
execution of the operations in the
database.
What is transaction
A set of logically related operations is known as a
transaction.

These operations are:-


1. Read(A)
2. Write(A)
What is Concurrency
Concurrency in a DBMS performing many simultaneous
operations without conflicting with each other.

Conflicts
Suppose we have 2 transaction T1 and T2

T1 T2 Conflict(Yes/No)
R(A) R(A) No conflict
R(A) W(A) Yes
W(A) R(A) Yes
W(A) W(A) Yes
Understand by an Example………………
Suppose we have 2 transaction T1 &T2 and it perform simultaneously………….

T1 T2
R(A)
W(A)
R(A)
W(A)

R(A)

To maintain the consistency of multiple transactions we use Concurrency control techniques….


CONCURRENCY CONTROL
TECHNIQUES
Concurrency control techniques are used in DBMS to ensure that
multiple transactions can execute simultaneously without leading to
data inconsistency.

There are various concurrency techniques in DBMS :-


1. Share & Exclusive protocol
2. Lock based protocol
3. Multi-version protocol
4. Time Stamp protocol
LOCK BASED PROTOCOL
• A lock guarantees exclusive use of a data item to a current
transaction.
• To access a data item (Lock acquired).
• After completion of transaction (lock release).
• If one transaction accessed the data item then the other
transaction cannot access the same date item during the
first transaction in processing.
• After the completion of first transaction other transaction
can be access the data item.
There are various types of locks in DBMS:-

1. Shared & Exclusive lock


2. Binary Lock
3. 2 Phase Locking
Shared And Exclusive lock
Shared Lock:- • Multiple transaction can acquire shared lock on a resource
simultaneously.
Lock- S(A) • It perform only read operations for multiple transaction
simultaneously.

Exclusive Lock:- • Ensures only one transaction can modify a


resource at a time.
Lock - X(A) • Used for read and write operations to prevent
simultaneously modifications
Understand by an Example:-

T1 T2
Lock X(A)
R(A)
Exclusive
A-50
lock
W(A)
Unlock (A) Lock S(A)
Shared
R(A) lock R(A)
Binary Lock
• A binary lock can have 2 sates or values locked and unlocked.
• A distinct lock is associated with each database item A.
• These 2 values are:-
1. Lock- 1
2. Unlock- 0

• If the value of the lock on A is 1, item A cannot be accessed by a database operation that requests the item.
• If the value of the lock on A is 0 then item can be accessed when requested.
Two Phase Locking
According to the rules of protocol, every transaction can be divides into two phases.
1. First a Growing phase, in which it acquires all the locks released but can not release any
locks.
2. Lastly a Shrinking Phase, in which it release its locks but can not acquire any new locks
Rules for 2 phase locking:-
• A transaction must acquire a lock on an item before
operating on the item. The lock may be read or write,
depending on the access needed.
• Once the transaction release a lock, it can never acquire any
new locks.
Example:-

T1 T2
L1(A) L2(A)
R(A) R2(A)
A=A+100 A=2*A
W1(A) W2(A)
L1(B) L2(B)
U1(A) U2(A)
R1(B) R2(B)
B=B+100 B=2*B
W1(B) W2(B)
U1(B) U2(B)
Variations of 2 phase locking protocol:-

1. Conservative(Static) 2PL(After commit only if lock release)


2. Strict 2PL(Until commit here exclusive lock cannot be released)
3. Rigorous 2PL(Shared & Exclusive cannot be release until commit)
QNA
THANKYOU

You might also like