There are three tasks in this project milestone. Since the code is missing in functionality, test programs may not pass until you correctly implement the required components. The tasks listed below assume you are already familiar with the code base (including and especially those we provided to you). Make sure you understand the code very well before attempting.
2.1. Task 1 Lock Manager [50 marks]
This task focuses on the logical level concurrency control, i.e., locking. You need to implement a simple lock manager based on the ideas discussed in class (here and here).
The basic idea is to use a hash table as the lock table to track all locks and requests. You will need to implement lock acquire, release and other related functions. In this task, you do not need to consider deadlocks (i.e., assume they will never occur), which you will handle in the next task. The design is self-explanatory in the code given to you in lock_manager.{h,cc} so we will not repeat here. Start by understanding the code and follow the comments to add your implementation. Note that a new Transaction type is defined in yase.h. You should use it for your lock manager implementation and finish implementing its Commit and Abort functions. Check lock_manager_mttest.cc to get an idea how everything fits together for this task.
2.2. Task 2 Deadlock Prevention [30 marks]
Based on your implementation of Task 1, implement two policies: wait-die and no-wait. Under the wait-die policy, transaction Ti directly aborts if Tj is already holding the lock and Tj has higher priority (i.e., smaller timestamp). Under the no-wait policy, transaction Ti directly aborts if the lock cannot be granted immediately, regardless of priority.
The user code should be able to specify which policy to use by giving the corresponding constructor parameter to the lock manager; the parameter is already defined in the base code, you should use it in your lock manager code to decide which policy to take.
2.3. Task 3 Testing Your Code [20 marks]
Under the Tests directory a new test program (lock_manager_mttest.cc) is given to get you started on testing your code. You need to add one new test for the no-wait policy. You can follow the similar idea of the given wait-die policy to write the new test. Your test must use at least two threads. We will test your code using more complex cases so you are encouraged to use this code as a starting point and vary as many parameters as possible to test your code.
Reviews
There are no reviews yet.