-
Notifications
You must be signed in to change notification settings - Fork 0
Lock
yaxing edited this page Nov 13, 2011
·
1 revision
1. Lock Table data structure:
resourceName => lockList
HashMap<String, ArrayList<LockEnty>>
2. LockEnty structure:
int transacId; LockType type
3. Simple introduction:
a. Multiple transaction can hold READ lock on the same resource at the same time.
b. For one transaction T, if X's lock is only held by T, then T can hold both READ & WRITE lock on X.
e.g.
...
W(T1, X1, 2) // T1 and only T1 holds WRITE lock on X1
R(T1, X1) // since T1 owns all lock of X1, T1 can also read-lock X1, so T1 also holds READ lock on X1
...
After those operations, X1's lock would be:
X1=>{T1:WRITE, T1:READ}
c. If there is one WRITE lock on X1, X1 would be exclusively locked.
e.g.
in the former example, X1 is exclusively locked
d. If there are multiple READ lock from different transactions on X, and one transaction is T, X cannot be WRITE-locked by T following b's rule. In this situation, WRITE lock on X cannot be retrieved.