0

Now, I have two transactions here. The consistency requirement be A=0 v B=0, with A=B=0 the initial values

T1: read(A);
    read(B);
    if A=0 then B:=B+1;
    write(B).

T2: read(B);
    read(A);
    if B=0 then A:=A+1;
    write(A).

I know that there is no parallel execution resulting in a serializable schedule. So I want to apply two-phase locking to guarantee serializability.

How dose two-phase locking guarantee serializability? Can you give me one example of these two transactions?

Thank you.

dsolimano
  • 8,870
  • 3
  • 48
  • 63
  • What would two-phase locking mean in the context of this problem - lock A then B before entering either T1 or T2? – tariksbl May 04 '14 at 00:03

1 Answers1

0

As you mentioned there is no parallel execution resulting in a serializable schedule i.e the schedule is not conflict serializabe.

If a schedule is not conflict serializable then two-phase locking protocol leads to deadlock.So you cannot use two-phase locking to guarantee serializability.

akashchandrakar
  • 2,009
  • 3
  • 23
  • 47