diff --git a/.obsidian/workspace.json b/.obsidian/workspace.json index b752c08..7aa2533 100644 --- a/.obsidian/workspace.json +++ b/.obsidian/workspace.json @@ -53,7 +53,7 @@ "file": "Concurrent Systems/slides/class 7.pdf", "page": 10, "left": -23, - "top": 175, + "top": 90, "zoom": 0.680522565320665 }, "icon": "lucide-file-text", diff --git a/Concurrent Systems/notes/7- MUTEX-free concurrency.md b/Concurrent Systems/notes/7- MUTEX-free concurrency.md index ec8fe73..3e9414c 100644 --- a/Concurrent Systems/notes/7- MUTEX-free concurrency.md +++ b/Concurrent Systems/notes/7- MUTEX-free concurrency.md @@ -154,5 +154,25 @@ TOP : a register that can be read or compare&setted ``` 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 + 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 + +conclude(i, v, s) := + tmp <- STACK[i].val + STACK[i].compare&set(⟨tmp,s-1⟩,⟨v,s⟩) + +pop() := + 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 +``` +