From 8e1ea33ab8170ecf5b8a988cffc648dd37339d29 Mon Sep 17 00:00:00 2001 From: Marco Realacci Date: Mon, 17 Mar 2025 10:04:23 +0100 Subject: [PATCH] vault backup: 2025-03-17 10:04:23 --- .obsidian/workspace.json | 11 ++++++----- .../notes/{4b -.md => 4b - Monitors.md} | 12 ++++++------ Concurrent Systems/notes/4c - Dining Philosophers.md | 6 ++++++ 3 files changed, 18 insertions(+), 11 deletions(-) rename Concurrent Systems/notes/{4b -.md => 4b - Monitors.md} (97%) create mode 100644 Concurrent Systems/notes/4c - Dining Philosophers.md diff --git a/.obsidian/workspace.json b/.obsidian/workspace.json index 01f0c24..94c1b9c 100644 --- a/.obsidian/workspace.json +++ b/.obsidian/workspace.json @@ -13,12 +13,12 @@ "state": { "type": "markdown", "state": { - "file": "Concurrent Systems/notes/4b -.md", + "file": "Concurrent Systems/notes/4c - Dining Philosophers.md", "mode": "source", "source": false }, "icon": "lucide-file", - "title": "4b -" + "title": "4c - Dining Philosophers" } } ] @@ -34,9 +34,9 @@ "type": "pdf", "state": { "file": "Concurrent Systems/slides/class 4.pdf", - "page": 16, + "page": 17, "left": -27, - "top": 130, + "top": 78, "zoom": 0.5754156769596199 }, "icon": "lucide-file-text", @@ -218,8 +218,9 @@ }, "active": "6edd4157a160e462", "lastOpenFiles": [ + "Concurrent Systems/notes/4b - Monitors.md", + "Concurrent Systems/notes/4c - Dining Philosophers.md", "Concurrent Systems/slides/class 4.pdf", - "Concurrent Systems/notes/4b -.md", "Concurrent Systems/slides/class 5.pdf", "HCIW/slides/4 HUI2016-6-forcefeedback.pdf", "HCIW/slides/3b Haptic slides.pdf", diff --git a/Concurrent Systems/notes/4b -.md b/Concurrent Systems/notes/4b - Monitors.md similarity index 97% rename from Concurrent Systems/notes/4b -.md rename to Concurrent Systems/notes/4b - Monitors.md index 2b63763..a5362e1 100644 --- a/Concurrent Systems/notes/4b -.md +++ b/Concurrent Systems/notes/4b - Monitors.md @@ -1,4 +1,3 @@ -### Monitors Semaphores are hard to use in practice because quite low level Monitors provide an easier definition of concurrent objects at the level of Prog. Lang. It guarantees mutual exclusion. @@ -109,7 +108,7 @@ operation end_read() := operation begin_write() := WW++ - if (AR+AW != 0) then + if (AR + AW != 0) then CW.wait() AW++ WW-- @@ -145,15 +144,16 @@ operation end_read() := operation begin_write() := WW++ - if (AR+AW != 0) then + if (AR + AW != 0) then CW.wait() AW++ WW-- operation end_write() := AW-- - if WW > 0 then - CW.signal() - else + if WR > 0 then CR.signal() + else + CW.signal() ``` +This way nobody gets starved forever. \ No newline at end of file diff --git a/Concurrent Systems/notes/4c - Dining Philosophers.md b/Concurrent Systems/notes/4c - Dining Philosophers.md new file mode 100644 index 0000000..d4c017d --- /dev/null +++ b/Concurrent Systems/notes/4c - Dining Philosophers.md @@ -0,0 +1,6 @@ +The first real practical example of a concurrent system. + +- $N$ philosophers seated around a circular table +- one chopstick between each pair of philosophers +- a philosophers must pick up its two nearest chopsticks in order to eat +- a philosoph \ No newline at end of file