Binary Locks for concurrency control in DBMS

Share

Binary Locks

  • A binary lock can have two states or values: locked and unlocked ( 0 or 1)
  • A distinct lock is associated with each database item X.
  • if the value of the lock on X is 1. item X cannot be accessed by a DB operation that requests the item.
  • if the value of the lock on X is 0, the item can be accessed when requested.

if the simple binary locking scheme described above is used, every transaction must obey the following rules:

  1. A transaction T must issue operation Lock(A) before performing Read(A) or Write(A).
  2. T must issue Unlock(A) after finishing all operations.
  3. T will not issue a Lock(A) operation if the data item A is already locked by it.
  4. T will not issue an Unlock(A) operation if the data item A is not locked by it.

These rules must be enforced by the lock manager module of the DBMS.

At most one transaction can hold the lock on a particular item. Thus, no two transactions can access the same item concurrently.

Database Blogs : https://codewithsudeep.com/category/database/

Share
Sudeep Mishra

Sudeep Mishra

Healing

%d bloggers like this: