The Timestamp-Ordering Protocol
The timestamp-ordering protocol ensures that any conflicting read and write operations are executed in
timestamp order. This protocol operates as follows:
1. Suppose that transaction Ti issues read(Q).
a. If TS(Ti ) < W-timestamp(Q), then Ti needs to read a value of Q that was already overwritten.
Hence, the read operation is rejected, and Ti is rolled back.
b. If TS(Ti ) ≥ W-timestamp(Q), then the read operation is executed, and R-timestamp(Q) is set to
the maximum of R-timestamp(Q) and TS(Ti ).
2. Suppose that transaction Ti issues write(Q).
a. If TS(Ti ) < R-timestamp(Q), then the value of Q that Ti is producing was needed previously, and
the system assumed that that value would never be produced. Hence, the system rejects the write
operation and rolls Ti back.
b. If TS(Ti ) < W-timestamp(Q), then Ti is attempting to write an obsolete value of Q. Hence, the
system rejects this write operation and rolls Ti back.
c. Otherwise, the system executes the write operation and sets W-timestamp(Q) to TS(Ti ).
If a transaction Ti is rolled back by the concurrency-control scheme as result of issuance of either a read or
write operation, the system assigns it a new timestamp and restarts it.
To illustrate this protocol, we consider transactions T25 and T26. Transaction T25 displays the contents of
accounts A and B:
S.No T25 T26
1 read(B);
2 read(B)
3 B := B − 50
4 write(B)
5 read(A)
6 read(A)
7 display(A + B)
8 A := A + 50
9 write(A)
10 display(A + B)
Thomas’ write rule,
Suppose that transaction Ti issues write (Q).
1. If TS(Ti ) < R-timestamp(Q), then the value of Q that Ti is producing was previously needed, and it had
been assumed that the value would never be produced. Hence, the system rejects the write operation and
rolls Ti back.
2. If TS(Ti ) < W-timestamp(Q), then Ti is attempting to write an obsolete value of Q. Hence, this write
operation can be ignored.
3. Otherwise, the system executes the write operation and setsW-timestamp(Q) to TS(Ti ).
S.NO T27 T28
1 Read(Q)
2 Write(Q)
3 Write(Q)