From 24539ddb1183691d4defb7c9ff3379f2c2ab7695 Mon Sep 17 00:00:00 2001 From: Marco Realacci Date: Fri, 4 Apr 2025 23:39:27 +0200 Subject: [PATCH] vault backup: 2025-04-04 23:39:27 --- .obsidian/workspace.json | 10 +++++----- Concurrent Systems/notes/1 - CS Basics.md | 4 ++-- .../notes/10 - Implementing Consensus.md | 4 ++-- Concurrent Systems/notes/1b - Peterson algorithm.md | 6 +++--- Concurrent Systems/notes/2 - Fast mutex by Lamport.md | 6 +++--- Concurrent Systems/notes/2b - Round Robin algorithm.md | 2 +- .../notes/3b - Aravind's algorithm and improvements.md | 4 ++-- Concurrent Systems/notes/4 - Semaphores.md | 2 +- Concurrent Systems/notes/4c - Dining Philosophers.md | 2 +- .../notes/5 - Software Transactional Memory.md | 2 +- Concurrent Systems/notes/6 - Atomicity.md | 4 ++-- .../notes/6a - Alternatives to Atomicity.md | 4 ++-- Concurrent Systems/notes/7- MUTEX-free concurrency.md | 6 +++--- 13 files changed, 28 insertions(+), 28 deletions(-) diff --git a/.obsidian/workspace.json b/.obsidian/workspace.json index 734db24..a4a866a 100644 --- a/.obsidian/workspace.json +++ b/.obsidian/workspace.json @@ -13,12 +13,12 @@ "state": { "type": "markdown", "state": { - "file": "Concurrent Systems/notes/2 - Fast mutex by Lamport.md", + "file": "Concurrent Systems/notes/4c - Dining Philosophers.md", "mode": "source", "source": false }, "icon": "lucide-file", - "title": "2 - Fast mutex by Lamport" + "title": "4c - Dining Philosophers" } }, { @@ -65,7 +65,7 @@ "state": { "type": "search", "state": { - "query": "", + "query": "images/", "matchingCase": true, "explainSearch": false, "collapseAll": false, @@ -203,9 +203,10 @@ }, "active": "7c5b0ca6f7687800", "lastOpenFiles": [ + "Concurrent Systems/notes/4b - Monitors.md", "Concurrent Systems/notes/3a - Hardware primitives & Lamport Bakery algorithm.md", - "Concurrent Systems/notes/2 - Fast mutex by Lamport.md", "Concurrent Systems/notes/1 - CS Basics.md", + "Concurrent Systems/notes/2 - Fast mutex by Lamport.md", "Concurrent Systems/ignore this folder/Untitled.md", "Concurrent Systems/notes/4 - Semaphores.md", "Foundation of data science/notes/9 XGBoost.md", @@ -228,7 +229,6 @@ "Concurrent Systems/notes/6 - Atomicity.md", "Concurrent Systems/slides/class 5.pdf", "Concurrent Systems/notes/6a - Alternatives to Atomicity.md", - "Concurrent Systems/notes/4b - Monitors.md", "Concurrent Systems/notes/4c - Dining Philosophers.md", "Concurrent Systems/slides/class 4.pdf", "Concurrent Systems/slides/class 9.pdf", diff --git a/Concurrent Systems/notes/1 - CS Basics.md b/Concurrent Systems/notes/1 - CS Basics.md index 4132da9..6a226e1 100644 --- a/Concurrent Systems/notes/1 - CS Basics.md +++ b/Concurrent Systems/notes/1 - CS Basics.md @@ -62,7 +62,7 @@ function withdraw() { While `read()` and `write()` may be considered as atomic, their sequential composition **is not**. -![[images/Pasted image 20250303090135.png]] +![[/Concurrent Systems/notes/images/Pasted image 20250303090135.png]] #### Mutual Exclusion (MUTEX) Ensure that some parts of the code are executed as *atomic*. @@ -100,7 +100,7 @@ Every solution to a problem should satisfy at least: **Both inclusions are strict:** $$\text{Deadlock freedom} \not \implies \text{Starvation freedom}$$ - ![[images/Pasted image 20250303093116.png]] + ![[/Concurrent Systems/notes/images/Pasted image 20250303093116.png]] *p1 is starving!* $$\text{Starvation freedom} \not \implies \text{Bounded bypass}$$ Assume a $f$ and consider the scheduling above, where p2 wins $f(3)$ times and so does p3, then p1 looses (at least) $2f(3)$ times before winning. diff --git a/Concurrent Systems/notes/10 - Implementing Consensus.md b/Concurrent Systems/notes/10 - Implementing Consensus.md index 825dd31..6f77010 100644 --- a/Concurrent Systems/notes/10 - Implementing Consensus.md +++ b/Concurrent Systems/notes/10 - Implementing Consensus.md @@ -30,7 +30,7 @@ A configuration C obtained during the execution of all A is called: If A wait-free implements binary consensus for n processes, then there exists a bivalent initial configuration. *Proof:* -![[images/Pasted image 20250401083747.png]] +![[/Concurrent Systems/notes/images/Pasted image 20250401083747.png]] ### CN(Atomic R/W registers) = 1 **Thm:** There exists no wait-free implementation of binary consensus for 2 processes that uses atomic R/W registers. @@ -135,7 +135,7 @@ propose(i, v) := Let us consider a verison of the compare&swap where, instead of returning a boolean, it always returns the previous value of the object, i.e.: -![[images/Pasted image 20250401092557.png]] +![[/Concurrent Systems/notes/images/Pasted image 20250401092557.png]] ``` CS a compare&swap object init at ⊥ diff --git a/Concurrent Systems/notes/1b - Peterson algorithm.md b/Concurrent Systems/notes/1b - Peterson algorithm.md index 3be414e..8c3d8a9 100644 --- a/Concurrent Systems/notes/1b - Peterson algorithm.md +++ b/Concurrent Systems/notes/1b - Peterson algorithm.md @@ -53,10 +53,10 @@ unlock(i) := **How has p0 entered its CS?** a) `FLAG[1] = down`, this is possible only with the following interleaving: -![[images/Pasted image 20250303100721.png]] +![[/Concurrent Systems/notes/images/Pasted image 20250303100721.png]] b) `AFTER_YOU = 1`, this is possible only with the following interleaving: -![[images/Pasted image 20250303100953.png]] +![[/Concurrent Systems/notes/images/Pasted image 20250303100953.png]] ##### Bounded Bypass proof (with bound = 1) - If the wait condition is true, then it wins (and waits 0). @@ -140,7 +140,7 @@ Easy to generalize to k-MUTEX. Peterson's algorithm cost $O(n^2)$ A first way to reduce this cost is by using a tournament of MUTEX between pairs of processes: -![[images/Pasted image 20250304082459.png|350]] +![[/Concurrent Systems/notes/images/Pasted image 20250304082459.png|350]] Of course this is a binary tree, and the height of a binary tree is logaritmic to the number of leaves. A process then wins after $\lceil \log_{2}n \rceil$ competitions $\to O(\log n)$ cost. diff --git a/Concurrent Systems/notes/2 - Fast mutex by Lamport.md b/Concurrent Systems/notes/2 - Fast mutex by Lamport.md index 1f9e27b..1f2b923 100644 --- a/Concurrent Systems/notes/2 - Fast mutex by Lamport.md +++ b/Concurrent Systems/notes/2 - Fast mutex by Lamport.md @@ -49,9 +49,9 @@ unlock(i) := ##### MUTEX proof How can pi enter its CS? -![[images/Pasted image 20250304084537.png]] +![[/Concurrent Systems/notes/images/Pasted image 20250304084537.png]] -![[images/Pasted image 20250304084901.png]] +![[/Concurrent Systems/notes/images/Pasted image 20250304084901.png]] (*must finished before nel senso che $p_i$ deve aspettare $p_j$*) ##### Deadlock freedom Let $p_i$ invoke lock @@ -72,6 +72,6 @@ Let $p_i$ invoke lock - In the second wait Y = ⊥: but then there exists a $p_h$ that eventually enters its CS -> good - In the ∀j.wait FLAG[j]=down: this wait cannot block a process forever -![[images/Pasted image 20250304090219.png]] +![[/Concurrent Systems/notes/images/Pasted image 20250304090219.png]] esercizio: prova che NON soddisfa starvation freedom \ No newline at end of file diff --git a/Concurrent Systems/notes/2b - Round Robin algorithm.md b/Concurrent Systems/notes/2b - Round Robin algorithm.md index 30961b1..fcda91c 100644 --- a/Concurrent Systems/notes/2b - Round Robin algorithm.md +++ b/Concurrent Systems/notes/2b - Round Robin algorithm.md @@ -50,5 +50,5 @@ By Deadlock freedom of RR, at least one process eventually unlocks The worst case is when TURN = *i+1* mod n when FLAG[i] is set. -![[images/Pasted image 20250304093223.png]] +![[/Concurrent Systems/notes/images/Pasted image 20250304093223.png]] diff --git a/Concurrent Systems/notes/3b - Aravind's algorithm and improvements.md b/Concurrent Systems/notes/3b - Aravind's algorithm and improvements.md index b1967aa..2941bb7 100644 --- a/Concurrent Systems/notes/3b - Aravind's algorithm and improvements.md +++ b/Concurrent Systems/notes/3b - Aravind's algorithm and improvements.md @@ -31,7 +31,7 @@ unlock(i) := *Proof:* by contradiction. Let's consider the execution of $p_i$ leading to its CS: -![[images/Pasted image 20250310172134.png]] +![[/Concurrent Systems/notes/images/Pasted image 20250310172134.png]] **Corollary** (of the MUTEX proof)**:** DATE is never written concurrently. @@ -57,7 +57,7 @@ Let's consider the execution of $p_i$ leading to its CS: **Theorem:** the algorithm satisfies bounded bypass with bound $2n-2$. *Proof:* -![[images/Pasted image 20250310103703.png]] +![[/Concurrent Systems/notes/images/Pasted image 20250310103703.png]] so by this, the very worst possible case is that my lock experiences that. It looks like I can experience at most $2n-1$ other critical sections, but it is even better, let's see: diff --git a/Concurrent Systems/notes/4 - Semaphores.md b/Concurrent Systems/notes/4 - Semaphores.md index 7a2c3a2..9dbc7a4 100644 --- a/Concurrent Systems/notes/4 - Semaphores.md +++ b/Concurrent Systems/notes/4 - Semaphores.md @@ -180,7 +180,7 @@ producer A: - so producer A will write at `BUF[0]` - but wait! Consumer B is still reading there - **Producer A doesn't give a fuck.** - ![[images/Pasted image 20250312121828.png|200]] + ![[/Concurrent Systems/notes/images/Pasted image 20250312121828.png|200]] *don't be like Producer A, be more like Bob, who always scans EMPTY before!* So the issue here is that producers just assume that IN is the first available slot. But it its not necessarily the case. diff --git a/Concurrent Systems/notes/4c - Dining Philosophers.md b/Concurrent Systems/notes/4c - Dining Philosophers.md index f29ae93..0edf2af 100644 --- a/Concurrent Systems/notes/4c - Dining Philosophers.md +++ b/Concurrent Systems/notes/4c - Dining Philosophers.md @@ -3,7 +3,7 @@ The first real practical example of a concurrent system. - one chopstick between each pair of philosophers - a philosophers must pick up its two nearest chopsticks in order to eat - a philosopher must pick up first one chopstick, then the second one, not both at once -![[images/Pasted image 20250317100456.png|100]] +![[/Concurrent Systems/notes/images/Pasted image 20250317100456.png|100]] **PROBLEM:** *Devise a deadlock-free algorithm for allocating these limited resources (chopsticks) among several processes (philosophers).* diff --git a/Concurrent Systems/notes/5 - Software Transactional Memory.md b/Concurrent Systems/notes/5 - Software Transactional Memory.md index 427523b..4c389c8 100644 --- a/Concurrent Systems/notes/5 - Software Transactional Memory.md +++ b/Concurrent Systems/notes/5 - Software Transactional Memory.md @@ -105,7 +105,7 @@ The **casual past** of a transaction T is the set of all T' and T'' such that VWC allows more transactions to commit -> it is a more liberal property than opacity. -![[images/Pasted image 20250317105355.png]] +![[/Concurrent Systems/notes/images/Pasted image 20250317105355.png]] #### A Vector clock based STM system We have m shared MRMW registers; register X is represented by a pair XX, with: diff --git a/Concurrent Systems/notes/6 - Atomicity.md b/Concurrent Systems/notes/6 - Atomicity.md index cf42f57..5645a13 100644 --- a/Concurrent Systems/notes/6 - Atomicity.md +++ b/Concurrent Systems/notes/6 - Atomicity.md @@ -21,9 +21,9 @@ A complete history $\hat{H}$ is **linearizable** if there exists a sequential hi Given an history $\hat{K}$, we can define a binary relation on events $⟶_{K}$ s.t. (op, op’) ∈ ⟶K if and only if res[op] _{proc} op'$ to hold whenever there exists a process p that ### Sequential consistency **Def:** a complete history is sequentially consistent if there exists a sequential history $𝑆$ s.t. -![[images/Pasted image 20250324082534.png]] +![[/Concurrent Systems/notes/images/Pasted image 20250324082534.png]] -![[images/Pasted image 20250324082545.png]] +![[/Concurrent Systems/notes/images/Pasted image 20250324082545.png]] >[!warning] >The problem with sequential consistency is that it is NOT compositional. diff --git a/Concurrent Systems/notes/7- MUTEX-free concurrency.md b/Concurrent Systems/notes/7- MUTEX-free concurrency.md index 761172a..68ccb1b 100644 --- a/Concurrent Systems/notes/7- MUTEX-free concurrency.md +++ b/Concurrent Systems/notes/7- MUTEX-free concurrency.md @@ -64,7 +64,7 @@ this implementation satisfies the three requirements for the splitter - let us consider the last process that writes into LAST (this is an atomic register, so this is meaningful) - if the door is closed, it receives R and √ 3. let $p_i$ be the first process that receives $S \to LAST=i$ in its second if - ![[images/Pasted image 20250324091452.png]] + ![[/Concurrent Systems/notes/images/Pasted image 20250324091452.png]] ### An Obstruction-free Timestamp Generator A **timestamp generator** is a concurrent object that provides a single operation get_ts such that: @@ -98,7 +98,7 @@ this implementation satisfies the three properties of the timestamp generator - every process that starts after its termination will find NEXT to a greater value (NEXT never decreases!) 3. Obstruction freedom is trivial -**REMARK:** this implementation doesn’t satisfy the non-blocking property:![[images/Pasted image 20250324092633.png]] +**REMARK:** this implementation doesn’t satisfy the non-blocking property:![[/Concurrent Systems/notes/images/Pasted image 20250324092633.png]] ### A Wait-free Stack REG is an unbounded array of atomic registers (the stack) @@ -149,7 +149,7 @@ This is needed for the so called ABA problem with compare&set: - with the compare&set you mainly test that the sequence_number has not changed TOP : a register that can be read or compare&setted - ![[images/Pasted image 20250324100652.png]] + ![[/Concurrent Systems/notes/images/Pasted image 20250324100652.png]] ``` push(w) :=