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