From 8fa222cf5f4bc37b53bc17b0709ff09b8202f6c9 Mon Sep 17 00:00:00 2001 From: Marco Realacci Date: Mon, 3 Mar 2025 10:21:24 +0100 Subject: [PATCH] vault backup: 2025-03-03 10:21:24 --- Concurrent Systems/notes/Lezione1.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Concurrent Systems/notes/Lezione1.md b/Concurrent Systems/notes/Lezione1.md index 8ba2f1e..61cfb0d 100644 --- a/Concurrent Systems/notes/Lezione1.md +++ b/Concurrent Systems/notes/Lezione1.md @@ -181,4 +181,15 @@ b) `AFTER_YOU = 1`, this is possible only with the following interleaving: - It is possible tho that p1 locks again: - if p0 reads `F[1]` before p1 locks, then p0 wins (waiting 1) - - otherwise p1 sets A_Y to 1 and suspends in its wait (`F[0] = up AND A_Y = 1`), p0 will eventually rea \ No newline at end of file + - otherwise p1 sets A_Y to 1 and suspends in its wait (`F[0] = up AND A_Y = 1`), p0 will eventually read `F[1]` and win (waiting 1). + +### Peterson algorithm ($n$ processes) +- FLAG now has $n$ levels (from 0 to n-1) + - level 0 means down + - level >0 means inv +- Every level has its own AFTER_YOU + +``` +Initialize FLAG[i] to 0, for all i + +lock \ No newline at end of file