CS 357: Database Systems Implementation
Homework Assignment 5 -- Concurrency Control
| Given: |
Friday, 22 February |
| Due Date: |
Friday, 29 February |
SimpleDB currently uses timeout to detect deadlock. Change it so that it uses the
wait-die deadlock detection strategy. Your code should modify the class LockTable as follows:
- The methods sLock, xLock, and unLock will need to take the transaction id as an argument.
- The variable locks must be changed so that a block maps to a list of the transaction ids holding a
lock on the block (instead of just an integer). Use a negative transaction id to denote an exclusive lock.
- Each time through the while loop in sLock and
xLock, check to see if the thread needs to be aborted (that is, if there is a transaction on the list that is older than
the current transaction). If so, then the code should throw a LockAbortException.
You will also need to modify other classes that use LockTable. I'm sure you can figure out what those changes must be.
You must also write a test program. The program should generate at
least three threads (as in Figure 14-31 of the
text), which create various deadlock situations. You test class
can catch the LockAbort exception, in order to print out what happened
and continue.
As usual, submit a printout of each file you create or modify, with changes
indicated. NOTE: My solution required replacing a lot of code, but the resulting amount of code did not change much.