What
is Lock-based Protocol?
Lock-based protocol is a method by
which any transaction cannot be read or write data until it acquires
appropriate lock on database system.
Locks are of two kinds:
1. Binary Locks: A lock on a data item
can be in two states; it is either locked or unlocked.
2. Shared/exclusive Locks: This is when a lock is
acquired on a data item to execute a write operation.
What
is Simplistic Lock Protocol?
Simplistic lock-based protocols permit
transactions to acquire a lock on every object before a 'write' operation is executed.
What
is Pre-claiming Lock Protocol?
Pre-claiming protocols estimate their
operations and create a list of data items on which they need locks. Before starting
an execution, the transaction requests the system for all the locks it needs
beforehand. If all the locks are approved, the transaction performs and
releases all the locks when all its operations are over. If all the locks are
not approved, the transaction rolls back and waits until all the locks are
granted.
What
is Two-Phase Locking – 2pl?
This locking protocol separates the
execution phase of a transaction into three parts. In the first part, when the
transaction starts executing, it seeks permission for the locks it needs. The
second part is where the transaction obtains all the locks. As soon as the
transaction releases its first lock, the third phase starts. In this phase, the
transaction cannot demand any new locks; it only releases the obtained locks.
Two-phase locking has two phases, one
is growing, where all the locks are being obtained by the transaction; and the
second phase is shrinking, where the locks held by the transaction are being
released.
To claim an exclusive (write) lock, a
transaction must first obtain a shared (read) lock and then upgrade it to an
exclusive lock.
What
is Strict Two-Phase Locking?
The first phase of Strict-2PL is same
as 2PL. After obtaining all the locks in the first phase, the transaction
continues to perform normally. But in contrast to 2PL, Strict-2PL does not
release a lock after using it. Strict-2PL holds all the locks until the commit
point and releases all the locks at a time.
Reference: Tutorials Point | Wikipedia
No comments:
Post a comment