From 8a87dd23d725245f0a51866d7d7c8a0c8975df4d Mon Sep 17 00:00:00 2001 From: Marco Realacci Date: Mon, 17 Mar 2025 09:54:23 +0100 Subject: [PATCH] vault backup: 2025-03-17 09:54:23 --- Concurrent Systems/notes/4b -.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Concurrent Systems/notes/4b -.md b/Concurrent Systems/notes/4b -.md index 2928348..d11cef5 100644 --- a/Concurrent Systems/notes/4b -.md +++ b/Concurrent Systems/notes/4b -.md @@ -68,5 +68,24 @@ operation begin_read() := if AW != 0 then CR.wait() CR.signal() + AR++ + WR-- + +operation end_read() := + AR-- + if AR + WR = 0 then + CW.signal() + +operation begin_write() := + if (AR+WR != 0 or AW != 0) then + CW.wait() + AW++ + +operation end_write() := + AW-- + if WR > 0 then + CR.signal() + else + CW.signal() ``` \ No newline at end of file