Skip to content
Official PYQ · 2007

GATE CS 2007 Q64 — Transactions and Concurrency Control

Explain with AI

Consider the following schedules involving two transactions. Which one of the following statements is TRUE?

  • 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)
Choose one option
View worked solution

Answer: C

To determine if the schedules are conflict serializable, we construct the precedence graph for each schedule. A schedule is conflict serializable if and only if its precedence graph contains no cycles.

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

1. Analysis of Schedule S1S_1

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)

Let's identify the conflicting operations between different transactions:

  • Conflict on YY: r1(Y)r_1(Y) occurs before w2(Y)w_2(Y). This creates a dependency edge:
    T1→T2T_1 \to T_2
  • Conflict on XX: r2(X)r_2(X) occurs before w1(X)w_1(X). This creates a dependency edge:
    T2→T1T_2 \to T_1

Since there is a cycle (T1→T2→T1T_1 \to T_2 \to T_1) in the precedence graph, S1S_1 is not conflict serializable.

2. Analysis of Schedule S2S_2

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)

Let's identify the conflicting operations between different transactions:

  • Conflict on YY: w2(Y)w_2(Y) occurs before r1(Y)r_1(Y). This creates a dependency edge:
    T2→T1T_2 \to T_1
  • Conflict on XX: r2(X)r_2(X) occurs before w1(X)w_1(X). This creates a dependency edge:
    T2→T1T_2 \to T_1

The only directed edge in the precedence graph is T2→T1T_2 \to T_1. Since there are no cycles, S2S_2 is conflict serializable (with the equivalent serial order T2→T1T_2 \to T_1).

Thus, S1S_1 is not conflict serializable and S2S_2 is conflict serializable.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Transactions and Concurrency Control questions