From 513c546ab8673452af7096d5f9cf6b5719475870 Mon Sep 17 00:00:00 2001 From: Marco Realacci Date: Wed, 12 Mar 2025 11:49:27 +0100 Subject: [PATCH] vault backup: 2025-03-12 11:49:27 --- Concurrent Systems/notes/4 - Semaphores.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Concurrent Systems/notes/4 - Semaphores.md b/Concurrent Systems/notes/4 - Semaphores.md index 4a66f7b..2a00ca9 100644 --- a/Concurrent Systems/notes/4 - Semaphores.md +++ b/Concurrent Systems/notes/4 - Semaphores.md @@ -181,7 +181,7 @@ end_write() := GLOB_MUTEX.up() return ``` - +If readers keeps arriving, they surpass writers. But when a writer terminates a ##### Strong priority to Readers When a writer terminates, it activates the first reader, if there is any, or the first writer, otherwise. @@ -202,7 +202,7 @@ end_write() := W_MUTEX.up() return ``` - +This is prioritizing readers as `GLOB_MUTEX.up()` is called before `W_MUTEX.up()`, this is stronger that what it is done before. ##### Weak priority to Writers ``` GLOB_MUTEX, PRIO_MUTEX (to prioritize the writers), R_MUTEX and W_MUTEX semaphores init. at 1 @@ -241,4 +241,6 @@ def end_write() := if W = 0 then PRIO_MUTEX.up() W_MUTEX.up() - return \ No newline at end of file + return +``` +This is prioritizing writers as if there are writers waiting, they will be waiting at `GLOB_MUTEX.down()`. This semaphore is upped before `PRIO_MUTEX` which is the one that blocks readers. \ No newline at end of file