7 Example - CH 17 - Week 10 Precedence Graph
7 Example - CH 17 - Week 10 Precedence Graph
A schedule is said to be conflict serializable if it can transform into a serial schedule after
Conflicting operations
The two operations are called conflicting operations, if all the following three conditions are
satisfied:
Read-Write
Write-Write
Write-Read
Two schedules are called as a conflict equivalent schedule if one schedule can be
Algorithm:
1. Create the number of node in the graph equal to the number of transactions in the given
schedule.
2. Starting with each and every transaction identify all the existing conflicting operations and
represent them in the graph in the form of edges following the direction of the conflicting
operation.
• The set of edges consists of all edges Ti→ Tjfor which one of three conditions holds:
1. Tiexecutes write(Q) before Tjexecutes read(Q).
2. Tiexecutes read(Q) before Tjexecutes write(Q).
3. Tiexecutes write(Q) before Tjexecutes write(Q).
3. Check if the precedence graph has either a cycle or a loop.
4. If the cycle or loop does exist, then the given schedule is not conflict serializable.
5. Else the schedule is conflict serializable.
6. In case the schedule is conflict serializable then apply the Topological ordering in the graph
to find out the equivalent serial schedule.
Topological Ordering:
The process of selecting the nodes with in-degree zero always, is known as topological ordering. while
applying this process, after selecting the node with in-degree zero, we shall ignore that node further
and also we should ignore the edges that were emerging from that selected node. From the remaining
graph we should continue finding the next node with in-degree zero until all the nodes of graph gets
selected.
For example, a topological sorting of the above graph is “5 4 2 3 1 0”. There can be more than one
topological sorting for a graph.
For example, another topological sorting of the above graph is “4 5 2 3 1 0”. The first vertex in
topological sorting is always a vertex with in-degree as 0 (a vertex with no incoming edges)
EXAMPLE
2. For the conflicting pair r1(x) w2(x), where r1(x) happens before w2(x), draw an edge from T 1 to T2.
3.
For the conflicting pair w2(x) w1(x), where w2(x) happens before w1(x), draw an edge from T2 to
T1.
Since the graph is cyclic, we can conclude that it is not conflict serializable to any schedule serial
schedule.
Let us try to infer a serial schedule from this graph using topological ordering.
T1 T2 T3
r1(x)
r3(y)
w1(x)
w2(y)
r3(x)
w2(x)
Since the graph is acyclic, the schedule is conflict serializable. Performing Topological Sort on
this graph would give us a possible serial schedule which is conflict equivalent to schedule S1.
In Topological Sort, we first select the node with indegree 0, which is T1. This would be followed
by T3 and T2.
So, S1 is conflict serializable since it is conflict equivalent to the serial schedule T1 T3 T2.
`````````````````````````````````````````````````````````