Question

Consider the following four schedules due to three transactions (indicated by the subscript) using read and write on a data item x, denoted by r(x) and w(x) respectively. Which one of them is conflict serializable?

Choose one option
Official answer and solution
Official answer
D
From
Official GATE 2014 answer key

Solution

Construct the precedence (serialization) graph for each schedule and check for acyclicity.

A schedule is conflict serializable if and only if its precedence graph is directed and acyclic.

Two operations on the same data item conflict if at least one of them is a write and they belong to different transactions:

  • Schedule (A): r1(x);r2(x);w1(x);r3(x);w2(x)r_1(x); r_2(x); w_1(x); r_3(x); w_2(x)

    • r2(x)<w1(x)  ⟹  T2→T1r_2(x) < w_1(x) \implies T_2 \to T_1
    • w1(x)<w2(x)  ⟹  T1→T2w_1(x) < w_2(x) \implies T_1 \to T_2
      Cycle: T1↔T2T_1 \leftrightarrow T_2. Not conflict serializable.
  • Schedule (B): r2(x);r1(x);w2(x);r3(x);w1(x)r_2(x); r_1(x); w_2(x); r_3(x); w_1(x)

    • r1(x)<w2(x)  ⟹  T1→T2r_1(x) < w_2(x) \implies T_1 \to T_2
    • w2(x)<w1(x)  ⟹  T2→T1w_2(x) < w_1(x) \implies T_2 \to T_1
      Cycle: T1↔T2T_1 \leftrightarrow T_2. Not conflict serializable.
  • Schedule (C): r3(x);r2(x);r1(x);w2(x);w1(x)r_3(x); r_2(x); r_1(x); w_2(x); w_1(x)

    • r1(x)<w2(x)  ⟹  T1→T2r_1(x) < w_2(x) \implies T_1 \to T_2
    • w2(x)<w1(x)  ⟹  T2→T1w_2(x) < w_1(x) \implies T_2 \to T_1
      Cycle: T1↔T2T_1 \leftrightarrow T_2. Not conflict serializable.
  • Schedule (D): r2(x);w2(x);r3(x);r1(x);w1(x)r_2(x); w_2(x); r_3(x); r_1(x); w_1(x)

    • w2(x)<r3(x)  ⟹  T2→T3w_2(x) < r_3(x) \implies T_2 \to T_3
    • w2(x)<r1(x)  ⟹  T2→T1w_2(x) < r_1(x) \implies T_2 \to T_1
    • w2(x)<w1(x)  ⟹  T2→T1w_2(x) < w_1(x) \implies T_2 \to T_1
    • r3(x)<w1(x)  ⟹  T3→T1r_3(x) < w_1(x) \implies T_3 \to T_1
      Edges in graph: T2→T3T_2 \to T_3 and T3→T1T_3 \to T_1 (and T2→T1T_2 \to T_1).
      There are no cycles! A valid topological ordering is T2,T3,T1T_2, T_3, T_1.

Thus, schedule D is conflict serializable.

Final answer

D

Common trap

Overlooking write-read or read-write conflicts between early and late transactions.

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

Source

Paper
GATE 2014 Computer Science and Information Technology (CS) Session 1
Question
39 of 65, printed as CS Q.29
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.