Professional Documents
Culture Documents
Concurrent Execution
KALINGA INSTITUTE OF INDUSTRIAL
TECHNOLOGY
School Of Computer
Engineering
Concurrent Execution
Schedules
Serial Schedule
Concurrent Schedule
Equivalent Schedule
Result Equivalent Schedule
Conflict Equivalent Schedule
Serializability
Conflict Serializability
Testing for Conflict Serializability
View Serializability
Concurrent Execution
3
Concurrent execution of transactions means executing more than one
transaction at the same time.
In the serial execution, one transaction can start executing only after the
completion of the previous.
The advantages of using concurrent execution of transactions are:
Improved throughput and resource utilization.
Reduced waiting time.
The database system must control the interaction among the concurrent
transactions to prevent them from destroying the consistency of the database. It
does this through a variety of mechanisms called concurrency control schemes.
T1 T2 T1 T2
Read(A); Read(A);
A:=A-100; Temp=0.2*A;
Write(A); A:=A-Temp;
Read(B); Write(A);
B:=B+100; Read(B);
Write(B); B:=B+Temp;
Read(A); Write(B);
Temp=0.2*A; Read(A);
A:=A-Temp; A:=A-100;
Write(A); Write(A);
Read(B); Read(B);
B:=B+Temp; B:=B+100;
Write(B); Write(B);
Schedule1 Schedule2
(T1 followed by T2) (T2 followed by T1)
Concurrent Schedule
6
In concurrent schedule, operations from different concurrent transactions are
interleaved.
The number of possible schedules for a set of n transactions is much larger than
n!.
T1 T2 T1 T2 T1 T2
Read(A); Read(A); Read(A);
A:=A-100; A:=A-100; A:=A-100;
Write(A); Read(A); Write(A);
Read(A); Temp=0.2*A; Read(A);
Temp=0.2*A; A:=A-Temp; Temp=0.2*A;
A:=A-Temp; Write(A); A:=A-Temp;
Write(A); Read(B); Read(B);
Read(B); Write(A); B:=B+100;
B:=B+100; Read(B); Write(A);
Write(B); B:=B+100; Read(B);
Read(B); Write(B); B:=B+Temp;
B:=B+Temp; B:=B+Temp; Write(B);
Write(B); Write(B); Write(B);
Schedule 3 Schedule 4 Schedule 5
Equivalent Schedule
7
Equivalent Schedule: Two schedules S1 and S2 are said to be equivalent
schedules, if they produce the same database state.
Result Equivalent Schedule: Two schedules are said to be result equivalent if
they produce the same final database state for some initial value of data.
Conflict Equivalent Schedule: Two schedules are said to be conflict
equivalent if all the conflicting operations in both the schedules must be
executed in the same order.
The conflicting operations are read-write, write-read and write-write
(different transaction, same data item, at least one write).
Ti Tj
Read(A) Write (A)
Write (A) Read (A)
Write (A) Write (A)
Read(A) Read(A)
Result Equivalent Schedule Example
8
The following schedules are result equivalent for the initial value of X and Y
( 2 and 5) respectively on not.
S1 S2
T1 T2 T1 T2
Read(X); Read(X);
X:=X+5; X=X * 3;
Write(X); Write(X);
Read(X); Read(X);
X=X * 3; X:=X+5;
Write(X); Write(X);
Read(Y);
Read(Y); Y:=Y+5;
Y:=Y+5; Write(Y);
Write(Y);
Conflict Equivalent Schedule Example
9
Check whether following schedules are conflict equivalent.
S1 S2
1. T1 T2 T1 T2
Read (X) Read (X)
Write(X) Write(X)
Read (X) Read(X)
Write(X) Read(Y)
Read (Y) Write (X)
Write (Y) Write(Y)
2.
S1: R1(A), R2(B), W1(A), W2(B)
S2: R2(B), R1(A), W2(B), W1(A)
T1 T2 T3 T1 T2 T3
Read(Q); Read(Q);
Write(Q); Write(Q);
Write(Q);
Write(Q);
Write(Q); Write(Q);
Schedule 7 Schedule 8
Yes Cycle
View
Serializable
Condition: No Cycle
Poly Graph View
Serializable
21