vault backup: 2025-04-03 00:10:03

This commit is contained in:
Marco Realacci 2025-04-03 00:10:03 +02:00
parent 90e5cc1e91
commit 018560c352
2 changed files with 38 additions and 3 deletions

View file

@ -13,12 +13,12 @@
"state": {
"type": "markdown",
"state": {
"file": "Concurrent Systems/notes/4b - Monitors.md",
"file": "Concurrent Systems/test/Untitled.md",
"mode": "source",
"source": false
},
"icon": "lucide-file",
"title": "4b - Monitors"
"title": "Untitled"
}
},
{
@ -206,8 +206,8 @@
},
"active": "7c5b0ca6f7687800",
"lastOpenFiles": [
"Concurrent Systems/notes/4 - Semaphores.md",
"Concurrent Systems/notes/4b - Monitors.md",
"Concurrent Systems/notes/4 - Semaphores.md",
"Concurrent Systems/notes/5 - Software Transactional Memory.md",
"Concurrent Systems/test/Untitled.md",
"Concurrent Systems/notes/4c - Dining Philosophers.md",

View file

@ -34,3 +34,38 @@ end_write() :=
GLOB_MUTEX.up()
return
```
```
monitor RW_READERS :=
AR, WR, AW, WW init at 0
condition CR, CW, CR_PR
operation begin_read() :=
WR++
if WW != 0 then
CR_PR.wait()
if AW != 0 then
CR.wait()
CR.signal()
AR++
WR--
operation end_read() :=
AR--
if AR = 0 then
CW.signal()
operation begin_write() :=
WW++
if (AR + AW != 0) then
CW.wait()
AW++
WW--
operation end_write() :=
AW--
if WR > 0 then
CR.signal()
else
CW.signal()
```