Show that the two-phase locking protocol ensures conflict 15.1 serializability,and that transactions can be serialized according to their lock points. Answer: Consider the following two transactions: 15.2 T34: read(A); read(B); A B B = 0 := + 1; if then write(B). T35: read(B); read(A); B A A = 0 := + 1; if then write(A). T31 T32, Add lock and unlock instructions to transactions and so that they observe the two-phase locking protocol. Can the execution of these transactions result in a deadlock? Answer: Lock and unlock instructions: a. T31: lock-S(A) read(A) lock-X(B) read(B) = 0 A if := + 1 B B then write(B) unlock(A) unlock(B) T32: lock-S(B) read(B) lock-X(A) read(A) = 0 B if := + 1 A A then write(A) unlock(B) unlock(A) Execution of these transactions can result in deadlock. For example, b. consider the following partial schedule:
15.1 Show that the two-phase locking protocol ensures conflict serializability,and that transactions can be serialized according to their lock points. Answer: 15.2 Consider the following two transactions: T34: read(A); read(B); if A = 0 then B := B + 1; write(B). T35: read(B); read(A); if B = 0 then A := A + 1; write(A). Add lock and unlock instructions to transactions T31 and T32, so that they observe the two-phase locking protocol. Can the execution of these transactions result in a deadlock? Answer: a. Lock and unlock instructions: T31: lock-S(A) read(A) lock-X(B) read(B) if A = 0 then B := B + 1 write(B) unlock(A) unlock(B) T32: lock-S(B) read(B) lock-X(A) read(A) if B = 0 then A := A + 1 write(A) unlock(B) unlock(A) b. Execution of these transactions can result in deadlock. For example, consider the following partial schedule:
fasl15(kiau-alborz.ir).docx