SlideShare a Scribd company logo
By
B.Sakthibala
I M.sc(cs)
 In a multiprogramming environment where
multiple transactions can be executed
simultaneously, it is highly important to
control the concurrency of transactions.
 We have concurrency control protocols to
ensure atomicity, isolation, and serializability
of concurrent transactions. Concurrency
control protocols can be broadly divided into
two categoriess
 Lock based protocols
 Two Phase Locking Protocol
Time stamp based protocols
Validation-Based Protocols
Lock-based Protocols:
 Database systems equipped with lock-based
protocols use a mechanism by which any
transaction cannot read or write data until it
acquires an appropriate lock on it.
 Locks are of two kinds
 Binary Locks
 Shared/exclusive
 Binary Locks − A lock on a data item can be in
two states; it is either locked or unlocked.
Shared/exclusive:
This type of locking mechanism differentiates the
locks based on their uses. If a lock is acquired
on a data item to perform a write operation, it
is an exclusive lock.
 1. Shared Lock (S):
 A shared lock is also called a Read-only lock.
With the shared lock, the data item can be
shared between transactions.
 2. Exclusive Lock (X):
 With the Exclusive Lock, a data item can be
read as well as written. This is exclusive and
can't be held concurrently on the same data
item. X-lock is requested using lock-x
instruction. Transactions may unlock the data
item after finishing the 'write' operation.
 3. Simplistic Lock Protocol
 This type of lock-based protocols allows
transactions to obtain a lock on every object before
beginning operation. Transactions may unlock the
data item after finishing the 'write' operation.
 4. Pre-claiming Locking
 Pre-claiming lock protocol helps to evaluate
operations and create a list of required data items
which are needed to initiate an execution process.
In the situation when all locks are granted, the
transaction executes.
 Starvation
 Starvation is the situation when a transaction
needs to wait for an indefinite period to acquire
a lock.
 Following are the reasons for Starvation:
 When waiting scheme for locked items is not
properly managed
 In the case of resource leak
 The same transaction is selected as a victim
repeatedly
 Two Phase Locking Protocol also known as
2PL protocol is a method of concurrency
control in DBMS that ensures serializability by
applying a lock to the transaction data which
blocks other transactions to access the same
data simultaneously. Two Phase Locking
protocol helps to eliminate the concurrency
problem in DBMS.
 The Two-Phase Locking protocol allows each
transaction to make a lock or unlock request in
two steps:
 Growing Phase: In this phase transaction may
obtain locks but may not release any locks.
 Shrinking Phase: In this phase, a transaction
may release locks but not obtain any new lock
 Strict Two-Phase Locking Method
 Strict-Two phase locking system is almost
similar to 2PL. The only difference is that Strict-
2PL never releases a lock after using it. It holds
all the locks until the commit point and releases
all the locks at one go when the process is over.
 Timestamp based Protocol in DBMS is an
algorithm which uses the System Time or
Logical Counter as a timestamp to serialize the
execution of concurrent transactions.
 Advantages:
 Schedules are serializable just like 2PL
protocols
 No waiting for the transaction, which
eliminates the possibility of deadlocks!
 Disadvantages:
 Starvation is possible if the same transaction is
restarted and continually aborted
 Validation Based Protocol
 Validation based Protocol in DBMS also
known as Optimistic Concurrency Control
Technique is a method to avoid concurrency in
transactions.
 In this protocol, the local copies of the
transaction data are updated rather than the
data itself, which results in less interference
while execution of the transaction.
 The Validation based Protocol is performed in
the following three phases:
 Read Phase
 Validation Phase
 Write Phase
 Read Phase:
 In the Read Phase, the data values from the
database can be read by a transaction but the
write operation or updates are only applied to
the local data copies, not the actual database.
 Validation Phase
 In Validation Phase, the data is checked to
ensure that there is no violation of
serializability while applying the transaction
updates to the database.
 Write Phase
 In the Write Phase, the updates are applied to
the database if the validation is successful, else;
the updates are not applied, and the
transaction is rolled back.
 Deadlock occurs when two or more
transactions are waiting to access the data
locked by the other transaction.
 Neither transaction can continue because each
is waiting for a lock it cannot obtain until the
other completes.
 Necessary conditions for Deadlock
 Mutual Exclusion
 No Preemption
 Hold & Wait
 Circular Wait
 Mutual Exclusion:
 This means that some of the resources involved
cannot be used by more than one process at the
same time.
 No Preemption: If a process is holding a
resource then its resources can not be forcibly
taken from it.
 Hold & Wait: The process is holding some
resources and is waiting for the other
resources.
 Circular Wait: The process is waiting for the
resource which is being held by the next
process and this forms a chain of waiting.
 Deadlock Ignorance
 This is the widely used technique to handle the
deadlock. Whenever a deadlock situation
occurs we simply ignore the deadlock.
 The deadlock occurs very rarely. So, why to
write a full-fledged code to remove the
deadlock
 Deadlock Prevention
 There is a very famous proverb. “Prevention is
better than cure”. So we try to prevent the
deadlock from happening.
 As we know here are four necessary conditions
for deadlock to occur. We will prevent any or
all of the conditions from holding true.
 Removing Mutual Exclusion
 Removing No Preemption
 Removing Hold & Wait Condition
 Removing Circular Wait
 Removing Mutual Exclusion: The resources
which we use should be sharable. Like CPU, it
can be used by more than one process at a
time.
 Some resources are non-sharable like printers.
So, if the resources are non-sharable then this
condition cannot be removed and hence the
deadlock can't be prevented.
 Removing No Preemption: Here, we will
forcibly preempt or stop a process and thus, the
resources held by this process will be released.
 Removing Hold & Wait Condition:
 Before a process starts we will give all the
resources required by it. Thus, a deadlock
situation will never arise as it will never have
to wait. Though this is practically impossible
because we can't simply give all the resources
to only one process.
 Removing Circular Wait: To avoid the circular
wait, the resource may be numbered and each
process can request the resource in increasing
order of these numbers. This algorithm if
implemented increases the complexity and
leads to poor resource utilization.
 Deadlock Avoidance
 Most of the deadlock prevention algorithms
have poor resource utilization or are practically
impossible. So, we can try to avoid deadlocks
by use of prior knowledge about the usage of
the resources available, resources allocated,
future resources requests, and future releases
by the processes.
 Deadlock Detection
 If deadlock prevention and avoidance are not done
properly then the system may enter a deadlock state.
So, we need to detect the deadlock and recover it.
 The deadlock once detected can be removed by the
following ways:
 Terminating the process involved in the
deadlock: This involves killing all the processes
involved in the deadlock until the deadlock is
removed.
 Resource Preemption: This involves taking back the
resources from the processes allocating it to other
processes so that deadlock is removed.
 THANKING YOU

More Related Content

PPTX
Deadlock in database
PDF
deadlock prevention
PPTX
operating system
PPTX
operating system
PPTX
Deadlock dbms
PPTX
Optimistic concurrency control in Distributed Systems
Deadlock in database
deadlock prevention
operating system
operating system
Deadlock dbms
Optimistic concurrency control in Distributed Systems

What's hot (13)

PPTX
Understanding isolation levels
PPTX
Concurrency control
DOC
Concurrency control
PPTX
Concurrent control
PPTX
protocols of concurrency control
PPTX
Concurrency control
PPT
Concurrency control
PPT
concurrency-control
PPTX
Concurrency Control in Database Management System
PPTX
Distributed datababase Transaction and concurrency control
PPTX
Transaction and concurrency control
PPTX
PPTX
Deadloack-Operating System
Understanding isolation levels
Concurrency control
Concurrency control
Concurrent control
protocols of concurrency control
Concurrency control
Concurrency control
concurrency-control
Concurrency Control in Database Management System
Distributed datababase Transaction and concurrency control
Transaction and concurrency control
Deadloack-Operating System
Ad

Similar to Rdbms (20)

PPTX
concurrency control
PDF
PPT-concurrency Control database management system DBMS concurrent control (U...
PPTX
Concurrency control PPT
PPTX
BCT 2312 - Chapter 3 - Concurrency Control Techniques in DBMSs.pptx
PPTX
Vani dbms
PPTX
CHapter four database managementm04.pptx
DOCX
Locking base concurrency control
PPT
Concurrency control ms neeti
PPT
Concurrency control ms neeti
PPTX
Concurrency control
PPTX
Concurrency Control in Databases.Database management systems
PDF
F017213747
PDF
F017213747
PDF
Design & Development of an Advanced Database Management System Using Multiver...
PDF
Concurrency Control in Database Management System
PPTX
Concurrency Control in RDBMS for Students.pptx
PPTX
Concurrency control
DOCX
Concurrency Control Techniques
PDF
Module 5 part-2 concurrency control in dbms
PPTX
Overview of Concurrency Control & Recovery in Distributed Databases
concurrency control
PPT-concurrency Control database management system DBMS concurrent control (U...
Concurrency control PPT
BCT 2312 - Chapter 3 - Concurrency Control Techniques in DBMSs.pptx
Vani dbms
CHapter four database managementm04.pptx
Locking base concurrency control
Concurrency control ms neeti
Concurrency control ms neeti
Concurrency control
Concurrency Control in Databases.Database management systems
F017213747
F017213747
Design & Development of an Advanced Database Management System Using Multiver...
Concurrency Control in Database Management System
Concurrency Control in RDBMS for Students.pptx
Concurrency control
Concurrency Control Techniques
Module 5 part-2 concurrency control in dbms
Overview of Concurrency Control & Recovery in Distributed Databases
Ad

More from sakthibalabalamuruga (13)

PPTX
Software engineering
PPTX
Software engineering
PPTX
web programming
PPTX
compiler design
PPTX
Apache mahout and R-mining complex dataobject
PPTX
Computer network
PPTX
Operating system
PPTX
PPTX
Data structure and algorithm
PPTX
Remote method invocatiom
Software engineering
Software engineering
web programming
compiler design
Apache mahout and R-mining complex dataobject
Computer network
Operating system
Data structure and algorithm
Remote method invocatiom

Recently uploaded (20)

PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
01-Introduction-to-Information-Management.pdf
PPTX
PPH.pptx obstetrics and gynecology in nursing
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PDF
RMMM.pdf make it easy to upload and study
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
PPTX
Pharma ospi slides which help in ospi learning
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
Pre independence Education in Inndia.pdf
PPTX
Institutional Correction lecture only . . .
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Supply Chain Operations Speaking Notes -ICLT Program
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
01-Introduction-to-Information-Management.pdf
PPH.pptx obstetrics and gynecology in nursing
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
RMMM.pdf make it easy to upload and study
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
Pharma ospi slides which help in ospi learning
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Pre independence Education in Inndia.pdf
Institutional Correction lecture only . . .
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
STATICS OF THE RIGID BODIES Hibbelers.pdf
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...

Rdbms

  • 2.  In a multiprogramming environment where multiple transactions can be executed simultaneously, it is highly important to control the concurrency of transactions.  We have concurrency control protocols to ensure atomicity, isolation, and serializability of concurrent transactions. Concurrency control protocols can be broadly divided into two categoriess
  • 3.  Lock based protocols  Two Phase Locking Protocol Time stamp based protocols Validation-Based Protocols Lock-based Protocols:  Database systems equipped with lock-based protocols use a mechanism by which any transaction cannot read or write data until it acquires an appropriate lock on it.
  • 4.  Locks are of two kinds  Binary Locks  Shared/exclusive  Binary Locks − A lock on a data item can be in two states; it is either locked or unlocked.
  • 5. Shared/exclusive: This type of locking mechanism differentiates the locks based on their uses. If a lock is acquired on a data item to perform a write operation, it is an exclusive lock.
  • 6.  1. Shared Lock (S):  A shared lock is also called a Read-only lock. With the shared lock, the data item can be shared between transactions.  2. Exclusive Lock (X):  With the Exclusive Lock, a data item can be read as well as written. This is exclusive and can't be held concurrently on the same data item. X-lock is requested using lock-x instruction. Transactions may unlock the data item after finishing the 'write' operation.
  • 7.  3. Simplistic Lock Protocol  This type of lock-based protocols allows transactions to obtain a lock on every object before beginning operation. Transactions may unlock the data item after finishing the 'write' operation.  4. Pre-claiming Locking  Pre-claiming lock protocol helps to evaluate operations and create a list of required data items which are needed to initiate an execution process. In the situation when all locks are granted, the transaction executes.
  • 8.  Starvation  Starvation is the situation when a transaction needs to wait for an indefinite period to acquire a lock.  Following are the reasons for Starvation:  When waiting scheme for locked items is not properly managed  In the case of resource leak  The same transaction is selected as a victim repeatedly
  • 9.  Two Phase Locking Protocol also known as 2PL protocol is a method of concurrency control in DBMS that ensures serializability by applying a lock to the transaction data which blocks other transactions to access the same data simultaneously. Two Phase Locking protocol helps to eliminate the concurrency problem in DBMS.
  • 10.  The Two-Phase Locking protocol allows each transaction to make a lock or unlock request in two steps:  Growing Phase: In this phase transaction may obtain locks but may not release any locks.  Shrinking Phase: In this phase, a transaction may release locks but not obtain any new lock
  • 11.  Strict Two-Phase Locking Method  Strict-Two phase locking system is almost similar to 2PL. The only difference is that Strict- 2PL never releases a lock after using it. It holds all the locks until the commit point and releases all the locks at one go when the process is over.  Timestamp based Protocol in DBMS is an algorithm which uses the System Time or Logical Counter as a timestamp to serialize the execution of concurrent transactions.
  • 12.  Advantages:  Schedules are serializable just like 2PL protocols  No waiting for the transaction, which eliminates the possibility of deadlocks!  Disadvantages:  Starvation is possible if the same transaction is restarted and continually aborted
  • 13.  Validation Based Protocol  Validation based Protocol in DBMS also known as Optimistic Concurrency Control Technique is a method to avoid concurrency in transactions.  In this protocol, the local copies of the transaction data are updated rather than the data itself, which results in less interference while execution of the transaction.
  • 14.  The Validation based Protocol is performed in the following three phases:  Read Phase  Validation Phase  Write Phase  Read Phase:  In the Read Phase, the data values from the database can be read by a transaction but the write operation or updates are only applied to the local data copies, not the actual database.
  • 15.  Validation Phase  In Validation Phase, the data is checked to ensure that there is no violation of serializability while applying the transaction updates to the database.  Write Phase  In the Write Phase, the updates are applied to the database if the validation is successful, else; the updates are not applied, and the transaction is rolled back.
  • 16.  Deadlock occurs when two or more transactions are waiting to access the data locked by the other transaction.  Neither transaction can continue because each is waiting for a lock it cannot obtain until the other completes.
  • 17.  Necessary conditions for Deadlock  Mutual Exclusion  No Preemption  Hold & Wait  Circular Wait
  • 18.  Mutual Exclusion:  This means that some of the resources involved cannot be used by more than one process at the same time.  No Preemption: If a process is holding a resource then its resources can not be forcibly taken from it.
  • 19.  Hold & Wait: The process is holding some resources and is waiting for the other resources.  Circular Wait: The process is waiting for the resource which is being held by the next process and this forms a chain of waiting.
  • 20.  Deadlock Ignorance  This is the widely used technique to handle the deadlock. Whenever a deadlock situation occurs we simply ignore the deadlock.  The deadlock occurs very rarely. So, why to write a full-fledged code to remove the deadlock
  • 21.  Deadlock Prevention  There is a very famous proverb. “Prevention is better than cure”. So we try to prevent the deadlock from happening.  As we know here are four necessary conditions for deadlock to occur. We will prevent any or all of the conditions from holding true.
  • 22.  Removing Mutual Exclusion  Removing No Preemption  Removing Hold & Wait Condition  Removing Circular Wait  Removing Mutual Exclusion: The resources which we use should be sharable. Like CPU, it can be used by more than one process at a time.
  • 23.  Some resources are non-sharable like printers. So, if the resources are non-sharable then this condition cannot be removed and hence the deadlock can't be prevented.  Removing No Preemption: Here, we will forcibly preempt or stop a process and thus, the resources held by this process will be released.
  • 24.  Removing Hold & Wait Condition:  Before a process starts we will give all the resources required by it. Thus, a deadlock situation will never arise as it will never have to wait. Though this is practically impossible because we can't simply give all the resources to only one process.
  • 25.  Removing Circular Wait: To avoid the circular wait, the resource may be numbered and each process can request the resource in increasing order of these numbers. This algorithm if implemented increases the complexity and leads to poor resource utilization.
  • 26.  Deadlock Avoidance  Most of the deadlock prevention algorithms have poor resource utilization or are practically impossible. So, we can try to avoid deadlocks by use of prior knowledge about the usage of the resources available, resources allocated, future resources requests, and future releases by the processes.
  • 27.  Deadlock Detection  If deadlock prevention and avoidance are not done properly then the system may enter a deadlock state. So, we need to detect the deadlock and recover it.  The deadlock once detected can be removed by the following ways:  Terminating the process involved in the deadlock: This involves killing all the processes involved in the deadlock until the deadlock is removed.  Resource Preemption: This involves taking back the resources from the processes allocating it to other processes so that deadlock is removed.