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