Assignment 3

advertisement
ACS-4902
Assignment 3
due: March 19, 2014
1. Review questions
(20)
(a) What is the two-phase locking protocol? How does it
guarantee serializability?
(b) Describe the wait-die and wound-wait protocols for
deadlock prevention.
(c) Describe the cautious waiting, no waiting, and timeout
protocols for deadlock prevention.
(d) What is a timestamp? How does the system generate
timestamp?
ACS-4902
Assignment 3
due: March 19, 2013
2. Modify the data structure for multiple-mode locks (shared
and exclusive) and the algorithm for read_lock(X),
write_lock(X), and unlock(X) so that upgrading and
downgrading of locks are possible. (The lock and unlock
operations can be found on the course page under “figures
for Chapter 20”; Hint: The lock needs to check the
transaction id(s) that hold the lock, if any.)
(20)
read_lock (X):
B: if LOCK (X)="unlocked"
then begin LOCK ( X) "read-locked"; no_of_reads(X) 1
end
else if LOCK(X)="read-locked"
then no_of_reads(X)  no_of _reads(X) + 1
else begin wait (until LOCK (X)="unlocked" and
the lock manager wakes up the transaction);
go to B
end;
write_lock (X):
B: if LOCK (X)="unlocked"
then LOCK (X)  "write-locked"
else begin
wait (until LOCK(X)="unlocked" and
he lock manager wakes up the transaction);
go to B
end;
unlock_item (X):
if LOCK (X)="write-locked"
then begin LOCK (X) "unlocked;“ wakeup one of the waiting transactions, if any
end
else if LOCK(X)="read-locked"
then begin
no_of_reads(X)  no_of_reads(X) – 1;
if no_of_reads(X)=0
then begin LOCK (X)="unlocked"; wakeup one of the waiting transactions, if any
end
end;
ACS-4902
Assignment 3
due: March 19, 2013
3. Apply the timestamp ordering algorithm to the schedules
of Figure 19.8(b) and (c), and determine whether the
algorithm will allow the execution of the schedules. (the
figures can be found on the course page under “figures for
chapter 19”.)
(20)
ACS-4902
Assignment 3
due: March 19, 2013
4. The compatibility matrix of Figure 20.8 shows that IS and
IX locks are compatible. Explain why this is valid. (the
figures can be found on the course page under “figures for
chapter 20”.)
(20)
5. What is ‘certify’ lock? Explain why this kind of locks is
needed for multiversion 2PL.
(20)
IS
IX
S
SIX
X
IS
IX
S
SIX
X
yes
yes
yes
yes
no
yes
yes
no
no
no
yes
no
yes
no
no
yes
no
no
no
no
no
no
no
no
no
Download