vault backup: 2025-03-24 09:53:11
This commit is contained in:
parent
50df8f7b64
commit
0856621409
1 changed files with 28 additions and 0 deletions
|
@ -101,3 +101,31 @@ this implementation satisfies the three properties of the timestamp generator
|
||||||
**REMARK:** this implementation doesn’t satisfy the non-blocking property:![[Pasted image 20250324092633.png]]
|
**REMARK:** this implementation doesn’t satisfy the non-blocking property:![[Pasted image 20250324092633.png]]
|
||||||
|
|
||||||
### A Wait-free Stack
|
### A Wait-free Stack
|
||||||
|
REG is an unbounded array of atomic registers (the stack)
|
||||||
|
|
||||||
|
For all i, `REG[i]` can be:
|
||||||
|
- written
|
||||||
|
- read by the `swap(v)` primitives (that atomically writes a new value in it)
|
||||||
|
- initialized at `⊥`
|
||||||
|
|
||||||
|
NEXT is an atomic register (pointing at the next free location of the stack) that can be
|
||||||
|
- read
|
||||||
|
- `fetch&add`
|
||||||
|
- initialized at 1
|
||||||
|
|
||||||
|
```
|
||||||
|
push(v) :=
|
||||||
|
i <- NEXT.fetch&add(1)
|
||||||
|
REG[1] <- v
|
||||||
|
|
||||||
|
pop() :=
|
||||||
|
k <- NEXT-1
|
||||||
|
for i = k down to 1
|
||||||
|
tmp <- REG[1].swap(⊥)
|
||||||
|
if tmp != ⊥ then
|
||||||
|
return tmp
|
||||||
|
return ⊥
|
||||||
|
```
|
||||||
|
|
||||||
|
REMARK: crashes do not compromise progress!
|
||||||
|
PROBLEM: unboundedness of REG is not realistic
|
Loading…
Add table
Add a link
Reference in a new issue