Notes On Concurrency Control
Notes On Concurrency Control
In a multiprogramming environment where more than one transactions can be concurrently executed,
there exists a need of protocols to control the concurrency of transaction to ensure atomicity and
isolation properties of transactions.
Concurrency control protocols, which ensure serializability of transactions, are most desirable.
Concurrency control protocols can be broadly divided into two categories:
Binary Locks: a lock on data item can be in two states; it is either locked or unlocked.
Shared/exclusive: this type of locking mechanism differentiates lock based on their uses. If a
lock is acquired on a data item to perform a write operation, it is exclusive lock. Because allowing
more than one transactions to write on same data item would lead the database into an inconsistent
state. Read locks are shared because no data value is being changed.
There are four types lock protocols available:
Simplistic
Simplistic lock based protocols allow transaction to obtain lock on every object before 'write' operation
is performed. As soon as 'write' has been done, transactions may unlock the data item.
Pre-claiming
In this protocol, a transactions evaluations its operations and creates a list of data items on which it
needs locks. Before starting the execution, transaction requests the system for all locks it needs
beforehand. If all the locks are granted, the transaction executes and releases all the locks when all its
operations are over. Else if all the locks are not granted, the transaction rolls back and waits until all
locks are granted.
[Image: Pre-claiming]
The most commonly used concurrency protocol is time-stamp based protocol. This protocol uses either
system time or logical counter to be used as a time-stamp.
Lock based protocols manage the order between conflicting pairs among transaction at the time of
execution whereas time-stamp based protocols start working as soon as transaction is created.
Every transaction has a time-stamp associated with it and the ordering is determined by the age of the
transaction. A transaction created at 0002 clock time would be older than all other transaction, which
come after it. For example, any transaction 'y' entering the system at 0004 is two seconds younger and
priority may be given to the older one.
In addition, every data item is given the latest read and write-timestamp. This lets the system know,
when was last read and write operation made on the data item.
TIME-STAMP ORDERING PROTOCOL
The timestamp-ordering protocol ensures serializability among transaction in their conflicting read and
write operations. This is the responsibility of the protocol system that the conflicting pair of tasks
should be executed according to the timestamp values of the transactions.
Operation executed.