0% found this document useful (0 votes)
52 views2 pages

Bacsic TO

The BTO-TM algorithm provides timestamp-based concurrency control for distributed transactions. It assigns each transaction a timestamp and uses timestamps to determine the order of conflicting operations. The algorithm: 1) Assigns each transaction a timestamp when it begins. 2) Sends read/write operations to the appropriate site's scheduler along with the transaction timestamp. 3) The scheduler checks that the transaction timestamp is greater than any prior read/write timestamps for the data item before allowing the operation. 4) Operations are completed or the transaction is aborted and restarted if a conflict is detected.

Uploaded by

Long Trà
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)
52 views2 pages

Bacsic TO

The BTO-TM algorithm provides timestamp-based concurrency control for distributed transactions. It assigns each transaction a timestamp and uses timestamps to determine the order of conflicting operations. The algorithm: 1) Assigns each transaction a timestamp when it begins. 2) Sends read/write operations to the appropriate site's scheduler along with the transaction timestamp. 3) The scheduler checks that the transaction timestamp is greater than any prior read/write timestamps for the data item before allowing the operation. 4) Operations are completed or the transaction is aborted and restarted if a conflict is detected.

Uploaded by

Long Trà
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/ 2

Algorithm Basic Timestamp Ordering (BTO-TM) Algorithm

Input: msg : a message


begin
repeat
wait for a msg ;
switch msg type do
case transaction operation {operation from application program }
let op be the operation ;
switch op.Type do
case BT
S ← 0/ ; {S is the set of sites where transaction executes
}
assign a timestamp to transaction – call it ts(T ) ;
DP(op) {call DP with operation}
case R, W
find site that stores the requested data item (say Si ) ;
BTO-SCSi (op,ts(T )) ; {send op and ts to SC at Hi }
S ← S ∪ Si {build list of sites where transaction runs}
case A, C {send op to DPs at all sites where transaction
runs}
DPS (op)

case SC response {operation must have been rejected by one


SC}
op.Type ← A; {prepare an abort message}
BTO-SCS (op, −) ; {ask other SCs where transaction runs to
abort}
restart transaction with a new timestamp
case DP response {operation completed message}
switch transaction operation type do
let op be the operation ;
case R return op.val to the application ;
case W inform application of completion of the write ;
case C
if commit msg has been received from all participants
then
inform application of successful completion of
transaction
else {wait until commit messages come from all}
record the arrival of the commit message

case A
inform application of completion of the abort ;
BTO-SC(op) {need to reset read and write timestamps}

until forever ;
end
Timestamp-Based Concurrency Control Algorithms

Algorithm 11.5: Basic Timestamp Ordering Scheduler (BTO-SC) Algorithm


Input: op : Op; ts(T ) : Timestamp
begin
retrieve rts(op.arg) and wts(arg) ;
save rts(op.arg) and wts(arg) ; {might be needed if aborted }
switch op.arg do
case R
if ts(T) > wts(op.arg) then
DP(op) ; {operation can be executed; send it to the data
processor}
rts(op.arg) ← ts(T )
else
send “Reject transaction” message to coordinating TM
case W
if ts(T) > rts(op.arg) and ts(T) > wts(op.arg) then
DP(op) ; {operation can be executed; send it to the data
processor}
rts(op.arg) ← ts(T ) ;
wts(op.arg) ← ts(T )
else
send“Reject transaction” message to coordinating TM
case A
forall the op.arg that has been accessed by transaction do
reset rts(op.arg) and wts(op.arg) to their initial values

end

You might also like