simpledb.tx.concurrency
Class LockTable

java.lang.Object
  extended by simpledb.tx.concurrency.LockTable

 class LockTable
extends java.lang.Object

The lock table, which provides methods to lock and unlock blocks. If a transaction requests a lock that causes a conflict with an existing lock, then that transaction is placed on a wait list. There is only one wait list for all blocks. When the last lock on a block is unlocked, then all transactions are removed from the wait list and rescheduled. If one of those transactions discovers that the lock it is waiting for is still locked, it will place itself back on the wait list.

Author:
Edward Sciore

Constructor Summary
LockTable()
           
 
Method Summary
 void sLock(Block blk)
          Grants an SLock on the specified block.
(package private)  void unlock(Block blk)
          Releases a lock on the specified block.
(package private)  void xLock(Block blk)
          Grants an XLock on the specified block.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LockTable

LockTable()
Method Detail

sLock

public void sLock(Block blk)
Grants an SLock on the specified block. If an XLock exists when the method is called, then the calling thread will be placed on a wait list until the lock is released. If the thread remains on the wait list for a certain amount of time (currently 10 seconds), then an exception is thrown.

Parameters:
blk - a reference to the disk block

xLock

void xLock(Block blk)
Grants an XLock on the specified block. If a lock of any type exists when the method is called, then the calling thread will be placed on a wait list until the locks are released. If the thread remains on the wait list for a certain amount of time (currently 10 seconds), then an exception is thrown.

Parameters:
blk - a reference to the disk block

unlock

void unlock(Block blk)
Releases a lock on the specified block. If this lock is the last lock on that block, then the waiting transactions are notified.

Parameters:
blk - a reference to the disk block