Adobe Scan 09 Dec 2024
Adobe Scan 09 Dec 2024
Schedule
Serial
Schedule
Non-serial Serializable
Schedule Schedule
1. Serial Schedule: The serial schedule is a type of schedule where one transaction is executed
completely before starting another transaction. In the serial schedule, when the first transaction
completes its cyce, then the next transaction is executed.
For example: Suppose there are two transactions TI
has no intereaving of operations, then there are the and T2 which have some operations. If it
following two possible outcomes:
1. Execute all the operations of T1 which was
followed by all the operations of T2.
2. Execute all the operations of TI which was
followed by all the operations of T2.
" In the given (a) figure, Schedule A shows the serial
schedule where TI followed by T2..
" In the given (b) figure, Schedule B shows the serial
schedule where T2 followed by T1.
(a)
T1 T2 (b)
T1 T2
read(A);
A:=A- N:
write(A): read(A):
A:=A + M;
Time read(B); write(A):
B: B+N;
write(B); Time read(A):
A:= A-N;
read(A); write(A);
read(B):
A:=A+ M; B:- B +N;
write(A); write(B);
Schedule A
Schedule B
2. Non-serial Schedule:
(c) (d)
T1 T2 T1 T2
read(A): read(A);
A:- A N: A:A- N;
read(A); write(A);
A:A + M: read(A):
write(A): A:=A+ M:
Time read(B): write(A);:
write(A):
read(B):
B:- B+ N: Time
B:- B+ N:
write(B): write(B):
Schedule Schedule D,
3. Serializable sche dule: The serializability of schedules is used to find non-serial schedules that
alow the transaction to execute concurrently without interfering with one another.
" It identifies which schedules are correct when executio ns of the transaction have interleaving
of their operations.
" Anon-serial schedule will be serializab le if is result is equal to the result of its transactions
executed serially.
Here,
A)
Precedence graph for Schedule S
Ti Tj
Ifa precedence graph contains a single edge Ti Ti, then all the instructions of Ti are
executed before the first nstruction ofTj is executed.
" Ifa precedence graph for schedule S contains a cycle, then S is non-seriali zable. If the
precedence graph has no cycle, then S is known as serializable.
For example:
TI T2 T3
Read(A)
Rcad(B)
A:= fi(A)
Read(C)
B: (B)
Write(B)
C:= f(C)
Time Write(C)
Write(A) Read(B)
Read(A)
A:={(A)
Read(C)
Write(A)
C:= f(C)
Write(C)
B:- (B)
Write(B)
Schedule S1
Explanation:
Read(A): In Tl, DO subsequent writes to A, so no new edges
Read(B): In T2, no subsequent writes to B, so no new edges
Read(C): In T3, no subsequent writes to C, so no new edges
Write (B): B is subsequently read by T3, so add edge T2 ’ T3
Wite(C): Cis subsequently read by T1, so add edge T3 ’ TI -
Write(A): Ais subsequently read by T2, soadd edgeTI ’ T2
Write(A): In T2, no subsequent reads to A, so no new edges
Write(C): In T1, no sbsequent reads to C,so no new edges
Write (B): In T3, no subsequent reads to B, SO no new edges
Precedence graph for schedule S1:
T1
T2 T3
The precedence graph for scheduk Sl contains acycle that's why Scheduke SI is non
serializable.
T5 T6
T4
Read(A)
A:= fi(A)
Read(C)
Write(A)
A:= f2(C)
Read(B)
Write(C)
Read(A)
Read(C)
Time B: f3(B)
Wite(B)
C:- f4(C)
Read(B)
Write(C)
A:=fs(A)
Write(A)
B:= f6(B)
Write(B)
Schedule S2
Explanation:
Read(A): In T4,no subsequent writes to A, so no new edges
Read(C): In T4, no subsequent writes to C, so no new edges
Write(A): A is subsequently read by T5, so add cdge T4 ’ TS V
Read(B): In T5,no subsequent writes to B, so no new edges
Write(C): Cis subsequently read by T6, so add edge T4 ’ T6
Write (B);: Ais subsequently read by T6, so add edge TS ’ T6
Write(C): In T6, no subsequent reads to C, so no new edges
Write(A): In T5, no subsequent reads to A, so no new edges
Write (B): In T6, no subsequent reads to B, so no new edges
T5
TA T6
The precedence graph for schedule S2 contains no cycle that's why Schedule S2 is serializable.