Concurrency control coordinates simultaneous transaction execution in multiprocessing database.
Lock based protocols
The most method used to implement serializability is to allow a transaction to access data item only if it is holding a lock.
The lock to the data items is of two types,
- Exclusive mode(X):- Data item can be both read and written. If T1 is a transaction which has acquired an exclusive mode lock on data item Q, then T1 can both read and write Q.
- Shared mode (S):- Data item can only be read. If T1 is a transaction which has acquired a shared mode lock on data item Q, then T1 can only read and cannot write Q.
Any number of transactions can hold shared locks on an item, if a transaction holds an exclusive on a data item, no other transaction can hold lock on that item unless the lock is released.Example: T1: lock-S (A); Read (A);Unlock (A); Display (A);