From 72db12339db9d633d1fa8a8590af98493903ef30 Mon Sep 17 00:00:00 2001 From: Marco Realacci Date: Tue, 1 Apr 2025 19:16:56 +0200 Subject: [PATCH] vault backup: 2025-04-01 19:16:56 --- ...e primitives & Lamport Bakery algorithm.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Concurrent Systems/notes/3a - Hardware primitives & Lamport Bakery algorithm.md b/Concurrent Systems/notes/3a - Hardware primitives & Lamport Bakery algorithm.md index 155d6b4..e55759d 100644 --- a/Concurrent Systems/notes/3a - Hardware primitives & Lamport Bakery algorithm.md +++ b/Concurrent Systems/notes/3a - Hardware primitives & Lamport Bakery algorithm.md @@ -141,6 +141,25 @@ lock(i) := unlock(i) := MY_TURN[i] <- 0 + + + + + +lock(i) := + FLAG[i] <- up + max_turn <- max{MY_TURN[1],...,MY_TURN[n]} + if max_turn > 2n then + + + + FLAG[i] <- down + forall j != i + wait FLAG[j] = down + wait (MY_TURN[j] = 0 OR ⟨MY_TURN[i],i⟩ < ⟨MY_TURN[j],j⟩) + +unlock(i) := + MY_TURN[i] <- 0 ``` Se il ticket number è minore si ottiene l'accesso, se il ticket number è uguale, allora si vede il process ID minore.