• edited by
37,717 views
107 107 votes

Consider the following transactions with data items $P$ and $Q$ initialized to zero:
$${\begin{array}{|c|l|r|c|}\hline
   \textbf{$T_1$}&    \text{read (P);}\\ & \text{read (Q);} \\ & \text{if P = 0 then Q := Q + 1; }\\ &      \text{write (Q)}  \\ \hline   
\textbf{$T_2$}& \text{read (Q);}\\& \text{read (P);} \\ & \text{if Q = 0 then P := P + 1;}   \\ & \text{write (P)} \\     \hline
\end{array}}$$

Any non-serial interleaving of T1 and T2 for concurrent execution leads to

  1. a serializable schedule
  2. a schedule that is not conflict serializable
  3. a conflict serializable schedule
  4. a schedule for which a precedence graph cannot be drawn

10 Answers

Best answer
113 113 votes
Answer is (B).

Explanation: $T_1:r(P),r(Q),w(Q) T_2:r(Q),r(P),w(P).$

Now, consider any non serial schedule for example, $S:r_1(P),r_2(Q),r_1(Q),r2(P),w_1(Q),w_2(P).$

Now, draw a precedence graph for this schedule. Here there is a conflict from $T_1\to T_2$ and there is a conflict from $T_2\to T_1.$ Therefore, the graph will contain a cycle. So we can say that the schedule is not conflict serializable.
• edited by
44 44 votes

I found this way much simpler : 

 

10 10 votes
Answer is b:

As for any non serial interleaving it is necessary that read(p) for t1 is executed before write(p) for t2 and read(q) for t2 is executed before write(q) for t1.This will give you a cycle of length 2 in the precedence graph.
9 9 votes

P and Q are initialised to 0.

Consider the values of P and Q when T1 is executed followed by T2.

P=0 and Q=1

$T_2\rightarrow T_1$

P=1, Q=0

Consider another schedule

T1      T2
R(P)
R(Q)
        R(Q)
        R(P)
        if(Q=0),P=P+1
        W(P)
if (P=0), Q=Q+1
W(Q)

This execution would set values of P and Q both to 1.

As you can see, here consistency requirement the ACID property is broken. Consistency in results is not ensured.

Hence, any non-serial interleaving would never lead to a serial schedule.

Transactions T1 and T2 are inconsistent.

Answer-B

2 2 votes

Here, the "non-serial" in "non-serial interleaving" is superfluous (redundant). Interleaving, by its very nature, is non-serial.

You've been asked to interleave, which means, you cannot execute all operations of one transaction in a row followed by all operations of the other transaction. Otherwise it would just be a serial schedule, which we don't want.

Our schedule can start with the first operation of either T1 or T2 (it has to start somewhere). If you start with T1 in your schedule (read1 P) then you cannot end T1 (write1 Q) without first starting T2 (read2 Q). Similarly, if you start with T2 (read2 Q) then you cannot end T2 (write2 P) without first starting T1 (read1 P). In both cases, you are taking a serial(izable) schedule (T1 $\rightarrow$ T2 in the first case, and T2 $\rightarrow$ T1 in the second) and changing the order of two conflicting operations.

We know that the moment we change the order of a pair of conflicting operations in a serial (or serializable) schedule , the schedule no longer remains conflict serializable. Hence, B is the correct answer.

• edited by
1 1 vote

Answer (B)
Two or more actions are said to be in conflict if:
1) The actions belong to different transactions.
2) At least one of the actions is a write operation.
3) The actions access the same object (read or write).

The schedules S1 and S2 are said to be conflict-equivalent if the following conditions are satisfied:
1) Both schedules S1 and S2 involve the same set of transactions (including ordering of actions within each transaction).
2) The order of each pair of conflicting actions in S1 and S2 are the same.

A schedule is said to be conflict-serializable when the schedule is conflict-equivalent to one or more serial schedules.

Source: Wiki Page for Schedule

In the given scenario, there are two possible serial schedules:
1) T1 followed by T2
2) T2 followed by T1.
In both of the serial schedules, one of the transactions reads the value written by other transaction as a first step. Therefore, any non-serial interleaving of T1 and T2 will not be conflict serializable.

Answer:
Position:
Show:

Related questions

71 71 votes
5 answers 5 answers
23.7k
23.7k views
go_editor asked Apr 21, 2016
23,712 views
Consider the following relations $A, B$ and $C:$ $$\overset{\textbf{A}}{\begin{array}{|c|c|c|}\hline\\\textbf{Id}& \textbf{Name}& \textbf{Age} \\\hline12& \text{A...
108 108 votes
9 answers 9 answers
46.4k
46.4k views
gatecse asked Sep 29, 2014
46,438 views
Consider the following relations $A, B$ and $C:$$$\overset{\text{A}}{\begin{array}{|c|c|c|} \hline \text {ID} & \text {Name} & \text {Age} \\\hline\text{12}& \text{Arun}...
67 67 votes
4 answers 4 answers
20.8k
20.8k views
Arjun asked Sep 29, 2014
20,750 views
Suppose $R_{1} (\underline{A}, B)$ and $R_{2} (\underline{C}, D) $ are two relation schemas. Let $r_{1}$ and $r_{2}$ be the corresponding relation instances. $B$ is a for...
50 50 votes
7 answers 7 answers
26.6k
26.6k views
gatecse asked Aug 5, 2014
26,598 views
Given the basic ER and relational models, which of the following is INCORRECT?An attribute of an entity can have more than one valueAn attribute of an entity can be compo...