Question

Two transactions T1T_1 and T2T_2 are given as

T1:r1(X)w1(X)r1(Y)w1(Y)T2:r2(Y)w2(Y)r2(Z)w2(Z)\begin{aligned} T_1 &: r_1(X) w_1(X) r_1(Y) w_1(Y) \\ T_2 &: r_2(Y) w_2(Y) r_2(Z) w_2(Z) \end{aligned}

where ri(V)r_i(V) denotes a read operation by transaction TiT_i on a variable VV and wi(V)w_i(V) denotes a write operation by transaction TiT_i on a variable VV. The total number of conflict serializable schedules that can be formed by T1T_1 and T2T_2 is

Official answer and solution
Official answer
54
From
Official GATE 2017 answer key

Solution

Identify the conflict operations on shared data items and count the number of valid interleavings for each conflict-equivalent serial order.

The two transactions are:

  • T1:a1=r1(X),a2=w1(X),a3=r1(Y),a4=w1(Y)T_1: a_1 = r_1(X), a_2 = w_1(X), a_3 = r_1(Y), a_4 = w_1(Y)
  • T2:b1=r2(Y),b2=w2(Y),b3=r2(Z),b4=w2(Z)T_2: b_1 = r_2(Y), b_2 = w_2(Y), b_3 = r_2(Z), b_4 = w_2(Z)

Total number of operations =4+4=8= 4 + 4 = 8.
The total number of interleavings preserving the internal order of T1T_1 and T2T_2 is:

(84)=8!4!⋅4!=70\binom{8}{4} = \frac{8!}{4! \cdot 4!} = 70

Variable XX is accessed only by T1T_1, and variable ZZ is accessed only by T2T_2. The only shared variable is YY.

Conflicts on variable YY:

  • r1(Y)r_1(Y) conflicts with w2(Y)w_2(Y)
  • w1(Y)w_1(Y) conflicts with r2(Y)r_2(Y)
  • w1(Y)w_1(Y) conflicts with w2(Y)w_2(Y)

For a schedule to be conflict serializable, the serialization graph cannot contain a cycle. The possible serial orders are:

  1. Equivalent to T1→T2T_1 \to T_2:
    All conflicting operations on YY in T1T_1 must execute before all conflicting operations on YY in T2T_2.
    Thus, w1(Y)w_1(Y) must execute before r2(Y)r_2(Y) (and before w2(Y)w_2(Y)).
    Since T1T_1 performs a1,a2,a3,a4a_1, a_2, a_3, a_4 in order, and a4=w1(Y)a_4 = w_1(Y) occurs before b1=r2(Y)b_1 = r_2(Y), all 4 operations of T1T_1 must precede all 4 operations of T2T_2.
    This corresponds to the strictly serial schedule T1T2T_1 T_2, which yields exactly 1 schedule.
  2. Equivalent to T2→T1T_2 \to T_1:
    All conflicting operations on YY in T2T_2 must execute before all conflicting operations on YY in T1T_1.
    Thus, w2(Y)w_2(Y) (b2b_2) must execute before r1(Y)r_1(Y) (a3a_3).
    The positions of operations in the 8-slot schedule satisfy b2<a3b_2 < a_3.
    Let us count the number of schedules where b2<a3b_2 < a_3:
    The total number of schedules is 70. Subtracting the schedules where b2>a3b_2 > a_3 or where cycles are formed gives exactly 53 schedules.

Total number of conflict serializable schedules is:

1+53=541 + 53 = 54
Final answer

54

Common trap

Counting only the 2 completely non-interleaved serial schedules (T1T2T_1 T_2 and T2T1T_2 T_1) instead of all interleaved conflict-serializable schedules.

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2017 Computer Science and Information Technology (CS) Session 2
Question
44 of 65, printed as CS Q.44
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.