diff --git a/Concurrent Systems/notes/5 - Software Transactional Memory.md b/Concurrent Systems/notes/5 - Software Transactional Memory.md index 588b09c..33ec44d 100644 --- a/Concurrent Systems/notes/5 - Software Transactional Memory.md +++ b/Concurrent Systems/notes/5 - Software Transactional Memory.md @@ -63,7 +63,7 @@ begin_T() := birthdate(T) <- CLOCK + 1 X.read_T() := - if lc?(XX) != ⊥ then + if l?(XX) != ⊥ then return lc(XX).val lc(XX) <- XX if lc(XX).date >= birthdate(T) then @@ -127,10 +127,18 @@ begin_T() := read_set(T), write_set(T) <- ∅ t_depend_T <- p_depend_i -X.read_T() := - if lc?(XX) != ⊥ then - return lc(XX).val +X.read_T(i) := + if lc(XX) = ⊥ then + lc(XX) <- newloc lc(XX) <- XX + + read_set(T) <- read_set(T) U {X} + + t_depend_T[X] <- lc(XX).depend[X] + + if ∃ Y ∈ read_set(T) s.t. t_dependT[Y] < lc(XX).depend[Y] then + ABORT + if lc(XX).date >= birthdate(T) then ABORT read_set(T) <- read_set(T) U {X}