0
$\begingroup$

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)
 read(x)                  
 lock-i(x)
 x = x + v              
                           lock-s(y)
                            read(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

  read(y)
 lock-i(y)(cant acquire this lock since read lock on y is not released in transaction t2 ,hence t1 also waits)

 y = y + v              
 lock-x(y)
 write(y)
 unlock(y)

likewise both transactions enter into deadlock. No matter what examples I try to take I get a deadlock. Can anyone please give me a schedule where the transactions don't enter into deadlock and they follow the 2PL protocol.

$\endgroup$
  • $\begingroup$ Hello! We discourage posts that simply state a problem out of context, and expect the community to solve it. What have you tried? Where did you get stuck? We do not want to just do your assignment for you; we want you to gain understanding. However, as it is we do not know what your underlying problem is, so we can not begin to help. Assuming you tried to solve it yourself and got stuck, it may be helpful if you wrote your thoughts and what you could not figure out. If you are confused about some concept, rather than asking for the answer to the assignment, ask about the concept. $\endgroup$ – D.W. Oct 26 '15 at 0:30
  • $\begingroup$ I explained my problem now Sir.Please do help if possible $\endgroup$ – Sravya Oct 26 '15 at 12:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.