Skip to content
Official PYQ · 2021

GATE CS 2021 Set 1 Q32 — Transactions and Concurrency Control

Explain with AI

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
View worked solution

Answer: B

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

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 find the conflicting operations between transactions T1T_1 and T2T_2:

  • On item yy: r1(y)r_1(y) occurs before w2(y)w_2(y). Since r1(y)r_1(y) and w2(y)w_2(y) conflict, this creates a directed edge: T1→T2T_1 \to T_2
  • On item xx: r2(x)r_2(x) occurs before w1(x)w_1(x). Since r2(x)r_2(x) and w1(x)w_1(x) conflict, this creates a directed edge: T2→T1T_2 \to T_1

The precedence graph for S1S_1 contains the cycle T1→T2→T1T_1 \to T_2 \to T_1. Therefore, 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 find the conflicting operations between transactions T1T_1 and T2T_2:

  • On item xx: r2(x)r_2(x) occurs before w1(x)w_1(x). This creates a directed edge: T2→T1T_2 \to T_1
  • On item yy: w2(y)w_2(y) occurs before r1(y)r_1(y). This creates a directed edge: T2→T1T_2 \to T_1

The precedence graph for S2S_2 has only one directed edge, T2→T1T_2 \to T_1, and contains no cycles. Therefore, S2S_2 is conflict serializable (equivalent to the serial execution 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