Binary Locks

A binary lock can have 2 States or values

  • Locked (or 1) and
  • Unlocked (or 0)

We represent the current state( or value) of the lock associated with data item X as LOCK(X).

Operations used with Binary Locking

  1. lock_item : A transaction request access to an item by first issuing a lock_item(X) operation.
    • If LOCK(X) =1 or L(X) : the transaction is forced to wait.
    • If LOCK(X) = 0 or U(x) : it is set to 1( the transaction locks the item) and the transaction is a load to access item X.
  2. unlock_item : After using the data item the transaction issues an operation unlock(X), which sets the operation LOCK(X) to 0 i.e. unlocks the data item so that X may be accessed by another transactions.

Transaction Rules for Binary Locks

Every transaction must obey the following rules :

  • A transaction T must issue the lock(X) operation before any read(X) or write(X) operations in T.
  • A transaction T must issue the unlock(X) operation after all read(X) and write(X) operations in T.
  • If a transaction T already holds the lock on item X, then T will not issue a lock(X) operation.
  • If a transaction does not  holds the lock on item X, then T will not issue an unlock(X) operation.
Example :

Binary Locks

Points About Binary Locking :

  • A binary lock enforces mutual exclusion on the data item.
  • Serializability is not ensure i.e. may not eliminate non serializable schedule.
  • The binary locks are simple but restrictive and so are not used in practice.

Implementation of Binary Locks :

Binary lock is implemented using 3 fields plus a queue for transactions data waiting to access item.
The 3 fields are :

  1. Data_item_name
  2. LOCK
  3. Locking_transaction

To keep track of and control access to locks, DBMS has a lock manager subsystem. Items that are not in the lock table are considered to be unlocked. The system maintains only those records for the items that are currently lock in the lock table.

Previous Home Next
Concurrency Control Protocol Shared and Exclusive Locks


Incoming search terms:

  • binary lock in dbms
  • binary lock
  • binary locks in dbms
  • disadvantages of binary lock in dbms
  • explain tha binary lock
  • problem with binary lock in dbms

This article has 2 comments

Leave a Reply