Skip to content
Official PYQ · 2022

GATE CS 2022 Q29 — Transactions and Concurrency Control

Explain with AI

Let Ri(z)\textit{R}_{i}(z) and Wi(z)\textit{W}_{i}(z) denote read and write operations on a data element zz by a transaction Ti,\textit{T}_{i}, respectively. Consider the schedule S\textit{S} with four transactions.

S:  R4(x)R2(x)R3(x)R1(y)W1(y)W2(x)W3(y)R4(y)S: \; R_{4}(x) R_{2}(x) R_{3}(x)R_{1}(y) W_{1}(y) W_{2}(x) W_{3}(y) R_{4}(y)

Which one of the following serial schedules is conflict equivalent to S?\textit{S}?

Choose one option
View worked solution

Answer: A

To find the serial schedule that is conflict equivalent to the given schedule SS, we construct its precedence graph. In a precedence graph, a directed edge Ti→TjT_i \rightarrow T_j exists if there is a conflict between an operation in TiT_i and a subsequent operation in TjT_j.

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. Identify Conflicting Operations

For data item xx:

  • R4(x)R_4(x) occurs before W2(x)  ⟹  T4→T2W_2(x) \implies T_4 \rightarrow T_2
  • R3(x)R_3(x) occurs before W2(x)  ⟹  T3→T2W_2(x) \implies T_3 \rightarrow T_2

For data item yy:

  • R1(y)R_1(y) occurs before W3(y)  ⟹  T1→T3W_3(y) \implies T_1 \rightarrow T_3
  • W1(y)W_1(y) occurs before W3(y)  ⟹  T1→T3W_3(y) \implies T_1 \rightarrow T_3
  • W1(y)W_1(y) occurs before R4(y)  ⟹  T1→T4R_4(y) \implies T_1 \rightarrow T_4
  • W3(y)W_3(y) occurs before R4(y)  ⟹  T3→T4R_4(y) \implies T_3 \rightarrow T_4

2. Construct the Precedence Graph

Combining all the directed edges, we get:

  • T1→T3T_1 \rightarrow T_3
  • T1→T4T_1 \rightarrow T_4
  • T3→T4T_3 \rightarrow T_4
  • T3→T2T_3 \rightarrow T_2
  • T4→T2T_4 \rightarrow T_2

3. Topological Sort

We find the topological order of the vertices in this Directed Acyclic Graph (DAG):

  1. T1T_1 has an in-degree of 00. We select T1T_1 first.
  2. After removing T1T_1, the in-degree of T3T_3 becomes 00. We select T3T_3 next.
  3. After removing T3T_3, the in-degree of T4T_4 becomes 00. We select T4T_4 next.
  4. Finally, only T2T_2 remains, which has an in-degree of 00 now. We select T2T_2.

Thus, the unique topological sort is:

Topological Order: T1→T3→T4→T2\text{Topological Order: } T_1 \rightarrow T_3 \rightarrow T_4 \rightarrow T_2

This corresponds to the serial schedule T1→T3→T4→T2T_1 \rightarrow T_3 \rightarrow T_4 \rightarrow T_2.

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

Published
Report a correction
Keep exploringMore Transactions and Concurrency Control questions