# 2 phase locking with added increment mode

Suppose that a DBMS recognizes increment as an atomic operation, in addition to the read and write operations. Let $V$ be the value of the data item $X$.

The operation increment (X) by c sets the value of $X$ to $V + c$ in an atomic step. The value of $X$ is not available to the transaction unless the latter executes a read.

The table below shows the lock compatibility matrix for the three lock modes: share mode , exclusive mode,and increment mode.

|    S  |   X   |   I  |

-----------------------------
S    |  true | false | false|
------------------------------
X    | false | false | false|
------------------------------
I    | false | false | true |
------------------------------

a) Show that ,if all the transactions lock the data that they access in the corresponding mode , the two phase locking ensures serializability.

b) Show that the inclusion of increment mode allows for increased concurrency.

Where I got stuck: According to the lock compatibility matrix given in the problem, while a transaction is performing an increment operation on $X$ (acquired an increment lock) other transactions can simultaneously acquire increment lock on the same item $X$ and perform increment operations just like shared mode (where if a transaction holds read lock on an item $X$ other transactions too can acquire read lock on $X$ ) where as increment lock is conflict to read and write operations. So suppose the following non-serial schedule which follows 2PL

T1          |           T2

lock-s(x)
lock-i(x)
x = x + v
lock-s(y)
lock-x(x)
lock-s(y)
write(x)
unlock(x)
lock-i(y)(cant acquire this lock since read lock on y is not released in transaction t1 ,hence waits)
y = y + v