0% found this document useful (0 votes)
84 views4 pages

7 Example - CH 17 - Week 10 Precedence Graph

Conflict serializability requires that a schedule can be transformed into a serial schedule by swapping non-conflicting operations. Two operations conflict if they access the same data item and at least one is a write operation. A precedence graph algorithm can determine if a schedule is conflict serializable by checking for cycles - a cyclic graph indicates non-serializability. Topological sorting of an acyclic precedence graph provides an equivalent serial schedule.

Uploaded by

azozbed5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
84 views4 pages

7 Example - CH 17 - Week 10 Precedence Graph

Conflict serializability requires that a schedule can be transformed into a serial schedule by swapping non-conflicting operations. Two operations conflict if they access the same data item and at least one is a write operation. A precedence graph algorithm can determine if a schedule is conflict serializable by checking for cycles - a cyclic graph indicates non-serializability. Topological sorting of an acyclic precedence graph provides an equivalent serial schedule.

Uploaded by

azozbed5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Conflict Serializability

A schedule is said to be conflict serializable if it can transform into a serial schedule after

swapping of non-conflicting operations. It is a type of serializability that can be used to check

whether the non-serial schedule is conflict serializable or not.

Conflicting operations

The two operations are called conflicting operations, if all the following three conditions are

satisfied:

• Both the operation belongs to separate transactions.

• Both works on the same data item.

• At least one of them contains one write operation.

Note: Conflict pairs for the same data item are:

Read-Write

Write-Write

Write-Read

Conflict Equivalent Schedule

Two schedules are called as a conflict equivalent schedule if one schedule can be

transformed into another schedule by swapping non-conflicting operations.

PRECEDENCE GRAPH TO CHECK CONFLICT SERIALIZABLE SCHEDULE


Precedence graph algorithm can be used to find out whether the given concurrent schedule is
conflict serializable or not.

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

Consider the schedule S :

S : r1(x) r1(y) w2(x) w1(x) r2(y)


Note;
1- transaction 1 instructions
2- transaction 1 instructions
Equivalent table as follows;
T1 T2
r1(x)
r1(y)
w2(x)
w1(x)
r2(y)

Creating Precedence graph:


1. Make two nodes corresponding to Transaction T1 and T2.

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.

There is no node with indegree = 0


The edge T1–>T2 tells that T1 should come before T2 in the linear ordering.
The edge T2 –> T1 tells that T2 should come before T1 in the linear ordering.
So, we can not predict any particular order (when the graph is cyclic). Therefore, no serial schedule can be
obtained from this graph.
Consider the another schedule S1 :
S1: r1(x) r3(y) w1(x) w2(y) r3(x) w2(x)
Equivalent table as follows;

T1 T2 T3
r1(x)
r3(y)
w1(x)
w2(y)
r3(x)
w2(x)

The graph for this schedule is :

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.

`````````````````````````````````````````````````````````

You might also like