diff --git a/.obsidian/workspace.json b/.obsidian/workspace.json index 9b1fd63..c37f3de 100644 --- a/.obsidian/workspace.json +++ b/.obsidian/workspace.json @@ -34,9 +34,9 @@ "type": "pdf", "state": { "file": "Concurrent Systems/slides/class 3.pdf", - "page": 11, + "page": 12, "left": -26, - "top": 49, + "top": 15, "zoom": 0.57541567695962 }, "icon": "lucide-file-text", diff --git a/Concurrent Systems/notes/3.md b/Concurrent Systems/notes/3.md index a1e09b1..484bec2 100644 --- a/Concurrent Systems/notes/3.md +++ b/Concurrent Systems/notes/3.md @@ -194,4 +194,28 @@ Then, pj enters its CS, completes it, unlocks and then invokes lock again - If pi has entered the CS, √ - Otherwise, by Lemma1, MY_TURN[i] < MY_TURN[j], then pj cannot bypass pi again! - At worse, pi has to wait all other proceeses before entering its CS - - (indeed, since there is no deadlock, when pi is waiting somebody enters the CS) \ No newline at end of file + - (indeed, since there is no deadlock, when pi is waiting somebody enters the CS) + +### Aravind’s algorithm +Problem with Lamport's algorithm: registers must be unbounded (every invocation of lock potentially increases the counter by 1 -> domain of the registers is all natural numbers!) + +For all processes, we have a FLAG and a STAGE (both binary MRSW) and a DATE (MRMW) register that ranges from 1 to 2n. + +``` +For all i, initialize + FLAG[i] to down + STAGE[i] to 0 + DATE[i] to i + +lock(i) := + FLAG[i] <- up + repeat + STAGE[i] <- 0 + wait (foreach j != i, FLAG[j] = down OR DATE[i] < DATE[j]) + STAGE[i] <- 1 + until foreach j != i, STAGE[J] = 0 + +unlock(i) := + tmp <- +``` +