Question

Let ri(z)r_i(z) and wi(z)w_i(z) denote read and write operations respectively on a data item zz by a transaction TiT_i. Consider the following two schedules.

S1:r1(x)  r1(y)  r2(x)  r2(y)  w2(y)  w1(x)S_1: r_1(x) \; r_1(y) \; r_2(x) \; r_2(y) \; w_2(y) \; w_1(x)
S2:r1(x)  r2(x)  r2(y)  w2(y)  r1(y)  w1(x)S_2: r_1(x) \; r_2(x) \; r_2(y) \; w_2(y) \; r_1(y) \; w_1(x)

Which one of the following options is correct?

Choose one option
Official answer and solution
Official answer
B
From
Official GATE 2021 answer key

Solution

Construct the precedence (conflict) graph for each schedule and check for directed cycles.

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

Examine schedule S1:r1(x)  r1(y)  r2(x)  r2(y)  w2(y)  w1(x)S_1: r_1(x) \; r_1(y) \; r_2(x) \; r_2(y) \; w_2(y) \; w_1(x):

  • Operation r1(y)r_1(y) precedes w2(y)w_2(y) on item y  ⟹  T1→T2y \implies T_1 \rightarrow T_2.
  • Operation r2(x)r_2(x) precedes w1(x)w_1(x) on item x  ⟹  T2→T1x \implies T_2 \rightarrow T_1.
    The precedence graph contains a cycle T1→T2→T1T_1 \rightarrow T_2 \rightarrow T_1. Hence, S1S_1 is not conflict serializable.

Examine schedule S2:r1(x)  r2(x)  r2(y)  w2(y)  r1(y)  w1(x)S_2: r_1(x) \; r_2(x) \; r_2(y) \; w_2(y) \; r_1(y) \; w_1(x):

  • Operation r2(x)r_2(x) precedes w1(x)w_1(x) on item x  ⟹  T2→T1x \implies T_2 \rightarrow T_1.
  • Operations r2(y)r_2(y) and w2(y)w_2(y) precede r1(y)r_1(y) on item y  ⟹  T2→T1y \implies T_2 \rightarrow T_1.
    There are no conflicts where an operation of T1T_1 precedes an operation of T2T_2. The precedence graph contains only the edge T2→T1T_2 \rightarrow T_1, which is acyclic. Hence, S2S_2 is conflict serializable (equivalent to serial schedule T2,T1T_2, T_1).

Thus, S1S_1 is not conflict serializable, and S2S_2 is conflict serializable (option B).

Final answer

B

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

Source

Paper
GATE 2021 Computer Science and Information Technology (CS, Set-1)
Question
42 of 65, printed as CS Q.32
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.