I need answer for this question, please^^ Consider the following two transaction
ID: 3836114 • Letter: I
Question
I need answer for this question, please^^ Consider the following two transactions: T1 read(A); read(B); B = A+B; write(B); ____ T2 write(A); read(B); ____ Q1. Add a lock and unlock instructions so that transaction T1 and T2 observe two-phase locking protocol. Q2. Show how deadlock could happen. I need answer for this question, please^^ Consider the following two transactions: T1 read(A); read(B); B = A+B; write(B); ____ T2 write(A); read(B); ____ Q1. Add a lock and unlock instructions so that transaction T1 and T2 observe two-phase locking protocol. Q2. Show how deadlock could happen. I need answer for this question, please^^ T1 read(A); read(B); B = A+B; write(B); ____ T2 write(A); read(B); ____ Q1. Add a lock and unlock instructions so that transaction T1 and T2 observe two-phase locking protocol. Q2. Show how deadlock could happen.Explanation / Answer
Hi,
Please find below the answers-
Answer 1-
T1: lock-S(A)
read(A)
lock-X(B)
read(B)
if A=0
then B := B + 1
write(B)
unlock(A)
unlock(B)
T2: lock-S(A)
write(A)
lock-X(B)
read(B)
Answer 2- Below scenario lead to deadlock as the resource 'A' has been locked by T1 for read purpose and the Transaction T2 is looking for the write operation on resource 'A'. But this resource is currently locked by T1. In the same way T1 is looking for read operation B but this resource is locked by T2.
lock-S(A)
read(A)
lock-X(B)
lock-S(A)
write(A)
lock-X(B)
T1 T2lock-S(A)
read(A)
lock-X(B)
lock-S(A)
write(A)
lock-X(B)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.