From 19763a448397c3dae66df41e5fa61df1e6036686 Mon Sep 17 00:00:00 2001 From: Marco Realacci Date: Wed, 12 Mar 2025 11:14:27 +0100 Subject: [PATCH] vault backup: 2025-03-12 11:14:27 --- .obsidian/workspace.json | 4 ++-- Concurrent Systems/notes/4 - Semaphores.md | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.obsidian/workspace.json b/.obsidian/workspace.json index fbaa41b..f8b3faf 100644 --- a/.obsidian/workspace.json +++ b/.obsidian/workspace.json @@ -34,9 +34,9 @@ "type": "pdf", "state": { "file": "Concurrent Systems/slides/class 4.pdf", - "page": 5, + "page": 7, "left": -23, - "top": 391, + "top": 248, "zoom": 0.652019002375297 }, "icon": "lucide-file-text", diff --git a/Concurrent Systems/notes/4 - Semaphores.md b/Concurrent Systems/notes/4 - Semaphores.md index f1a1ebf..7c2d90a 100644 --- a/Concurrent Systems/notes/4 - Semaphores.md +++ b/Concurrent Systems/notes/4 - Semaphores.md @@ -101,7 +101,7 @@ B.consume() := B.produce(v) := FREE.down() SP.down() - while not EMPTY[in] do # there is at least an EMPTY cell, otherwise it would have been blocked + while not EMPTY[in] do IN <- (IN+1) mod k i <- IN EMPTY[IN] <- ff @@ -123,4 +123,10 @@ B.consume() := EMPTY[o] <- tt FREE.up() return tmp -``` \ No newline at end of file +``` +Thanks to the semaphores, we are sure that while loops will not go on forever! The loops starts only if there is at least a FREE / BUSY cell. + +#### (Multiple) Producers/Consumers - Wrong solution +EXERCISE - will do later + +#### The Readers/Writers problem