diff --git a/.obsidian/workspace.json b/.obsidian/workspace.json index 827bc21..b752c08 100644 --- a/.obsidian/workspace.json +++ b/.obsidian/workspace.json @@ -51,9 +51,9 @@ "type": "pdf", "state": { "file": "Concurrent Systems/slides/class 7.pdf", - "page": 9, + "page": 10, "left": -23, - "top": 171, + "top": 175, "zoom": 0.680522565320665 }, "icon": "lucide-file-text", @@ -237,6 +237,7 @@ "lastOpenFiles": [ "Concurrent Systems/slides/class 7.pdf", "Concurrent Systems/notes/7- MUTEX-free concurrency.md", + "Pasted image 20250324100652.png", "Pasted image 20250324092633.png", "Pasted image 20250324091452.png", "Concurrent Systems/notes/Pasted image 20250324082534.png", @@ -265,7 +266,6 @@ "Pasted image 20250318090733.png", "Concurrent Systems/slides/class 5.pdf", "Concurrent Systems/notes/images/Pasted image 20250317105355.png", - "Concurrent Systems/notes/images/Pasted image 20250317100456.png", "HCIW/slides/4 HUI2016-6-forcefeedback.pdf", "HCIW/slides/3b Haptic slides.pdf", "HCIW/slides/3Haptic interaction.pdf", diff --git a/Concurrent Systems/notes/7- MUTEX-free concurrency.md b/Concurrent Systems/notes/7- MUTEX-free concurrency.md index 07f7a62..ec8fe73 100644 --- a/Concurrent Systems/notes/7- MUTEX-free concurrency.md +++ b/Concurrent Systems/notes/7- MUTEX-free concurrency.md @@ -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 +``` \ No newline at end of file diff --git a/Pasted image 20250324100652.png b/Pasted image 20250324100652.png new file mode 100644 index 0000000..ff95fe8 Binary files /dev/null and b/Pasted image 20250324100652.png differ