diff --git a/Concurrent Systems/notes/5 - Software Transactional Memory.md b/Concurrent Systems/notes/5 - Software Transactional Memory.md index e3cce6a..25eefc2 100644 --- a/Concurrent Systems/notes/5 - Software Transactional Memory.md +++ b/Concurrent Systems/notes/5 - Software Transactional Memory.md @@ -146,24 +146,27 @@ X.read_T(i) := return lc(XX).val -X.write_T(v) := +X.write_T(i, v) := if lc(XX) = ⊥ then lc(XX) <- newloc lc(XX).val <- v write_set(T) <- write_set(T) U {X} -try_to_commit_T() := +try_to_commit_T(i) := lock all read_set(T) U write_set(T) - if ∃ Y ∈ read_set(T) s.t. - - ∀ X ∈ read_set(T) - if XX.date >= birthdate(T) then - release all locks - ABORT - tmp <- CLOCK.fetch&add(1)+1 - ∀ X ∈ write_set(T) - XX <- ⟨lc(XX).val, tmp⟩ + if ∃ Y ∈ read_set(T) s.t. t_dependT[Y] < YY.depend[Y] then release all locks - COMMIT + ABORT + # abortisco se ho letto un Y che è stato modificato dopo che io l'ho letto, giusto? + + ∀ X ∈ write_set(T) do + t_dependT[X] <- XX.depend[X]+1 + + ∀ X ∈ write_set(T) do + XX <- ⟨lc(XX).val, t_dependT⟩ + + release all locks + p_depend_i <- t_depend_T + COMMIT ``` \ No newline at end of file