From 7ffffd2d0f70ffe52c001126910cd0e241d8acf7 Mon Sep 17 00:00:00 2001 From: Marco Realacci Date: Wed, 12 Mar 2025 11:19:27 +0100 Subject: [PATCH] vault backup: 2025-03-12 11:19:27 --- .obsidian/workspace.json | 4 ++-- Concurrent Systems/notes/4 - Semaphores.md | 24 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/.obsidian/workspace.json b/.obsidian/workspace.json index f8b3faf..9499de3 100644 --- a/.obsidian/workspace.json +++ b/.obsidian/workspace.json @@ -34,9 +34,9 @@ "type": "pdf", "state": { "file": "Concurrent Systems/slides/class 4.pdf", - "page": 7, + "page": 8, "left": -23, - "top": 248, + "top": 421, "zoom": 0.652019002375297 }, "icon": "lucide-file-text", diff --git a/Concurrent Systems/notes/4 - Semaphores.md b/Concurrent Systems/notes/4 - Semaphores.md index 7c2d90a..0d586b2 100644 --- a/Concurrent Systems/notes/4 - Semaphores.md +++ b/Concurrent Systems/notes/4 - Semaphores.md @@ -130,3 +130,27 @@ Thanks to the semaphores, we are sure that while loops will not go on forever! T EXERCISE - will do later #### The Readers/Writers problem +- Several processes want to access a file +- Readers may simultaneously access the file +- At most one writer at a time +- Reads and writes are mutually exclusive + +>[!note] Remark +>this generalizes the MUTEX problem (MUTEX = RW with only writers) + +The read/write operations on the file will all have the following shape: +``` +conc_read() := + begin_read() + read() + end_read() + +conc_write() := + begin_write() + write() + end_write() +``` + +##### Weak priority to Readers +- If a reader arrives during a read, it can surpass possible writers already suspended (risk of starvation for the writes) +- When a writer terminates, it activates the first suspended process, irrispectively of whether it is a reader or a writer (so, the priority to readers is said «weak») \ No newline at end of file