What Is Lock, Define Binary Lock And What Are The Rules Enforced By Lock Manager?


1 Answers

Anonymous Profile
Anonymous answered
Every data item has a variable that describes the status of the item in terms of which operations can be applied to it, this variable known as lock. Normally every data item in the database has one lock.

Types of lock: there are two types of lock one is Binary lock and another is Shared/Exclusive lock.
Binary Lock: binary lock has 2 states as locked and unlocked. 1 is used for representing locked status and 0 is used for representing unlocked status. Each data item in database has distinct lock. If the value of lock on an item a is 1, then it means that item a cannot be accessed by a database operation. If the value of lock on an item a is 0, then that item can be accessed by any database operation which want to access.

Following are the rules which a transaction must obey. These rules are enforced by lock manager.
(1) If a transaction t wants to read-item (a) or write-item(a) operations then that transaction t must issue lock-item(a) operation first.
(2) After completing all read-item(a) and write-item(a) operations, transaction t must issue the operation unlock-item(a).
(3) A transaction t will issue an unlock-item(a) operation if and only if it already holds the lock on item a.
(4)If a transaction t already holds the lock on an item a then that transaction t will not issue a lock-item(a) operation.

Answer Question