vault backup: 2025-03-24 10:08:11

This commit is contained in:
Marco Realacci 2025-03-24 10:08:11 +01:00
parent a3859a8e9c
commit b99aea1134
3 changed files with 12 additions and 4 deletions

View file

@ -144,7 +144,15 @@ This is needed for the so called ABA problem with compare&set:
if X.compare&set(tmp, v) then ...
```
- this is to ensure that the value of X has not changed in the computation
- the problem is that X can be changed twice before compare&set
- the problem is that X can be changed twice before compare&set (e.g. it was A, it became B and than came back to A)
- solution: X is a pair ⟨val , seq_numb⟩, with the constraint that each modification of X increases its sequence_number
- with the compare&set you mainly test that the sequence_number has not changed
TOP : a register that can be read or compare&setted
![[Pasted image 20250324100652.png]]
```
push(w) :=
while true do ⟨i,v,s⟩ <- TOP
conclude(i,v,s) if i=k then return FULL newtop ß ⟨i+1,w,STACK[i+1].seq_num+1⟩ if TOP.compare&set(⟨i,v,s⟩,newtop) then return OK
```