vault backup: 2025-04-03 18:21:35

This commit is contained in:
Marco Realacci 2025-04-03 18:21:35 +02:00
parent 89e321ee81
commit 05b428be81
2 changed files with 40 additions and 6 deletions

View file

@ -27,12 +27,12 @@
"state": { "state": {
"type": "markdown", "type": "markdown",
"state": { "state": {
"file": "Concurrent Systems/notes/10 - Implementing Consensus.md", "file": "Concurrent Systems/test/Untitled.md",
"mode": "source", "mode": "source",
"source": false "source": false
}, },
"icon": "lucide-file", "icon": "lucide-file",
"title": "10 - Implementing Consensus" "title": "Untitled"
} }
} }
], ],
@ -207,14 +207,15 @@
}, },
"active": "e453bba00fdc57d6", "active": "e453bba00fdc57d6",
"lastOpenFiles": [ "lastOpenFiles": [
"Concurrent Systems/notes/9 - Consensus.md", "Concurrent Systems/notes/4b - Monitors.md",
"Concurrent Systems/notes/8 - Enhancing Liveness Properties.md",
"Concurrent Systems/notes/7- MUTEX-free concurrency.md", "Concurrent Systems/notes/7- MUTEX-free concurrency.md",
"Concurrent Systems/notes/8 - Enhancing Liveness Properties.md",
"Concurrent Systems/notes/6a - Alternatives to Atomicity.md", "Concurrent Systems/notes/6a - Alternatives to Atomicity.md",
"Concurrent Systems/notes/6 - Atomicity.md", "Concurrent Systems/notes/6 - Atomicity.md",
"Concurrent Systems/notes/5 - Software Transactional Memory.md", "Concurrent Systems/notes/5 - Software Transactional Memory.md",
"Concurrent Systems/notes/10 - Implementing Consensus.md",
"Concurrent Systems/notes/9 - Consensus.md",
"Concurrent Systems/notes/4c - Dining Philosophers.md", "Concurrent Systems/notes/4c - Dining Philosophers.md",
"Concurrent Systems/notes/4b - Monitors.md",
"Concurrent Systems/notes/4 - Semaphores.md", "Concurrent Systems/notes/4 - Semaphores.md",
"Concurrent Systems/notes/3b - Aravind's algorithm and improvements.md", "Concurrent Systems/notes/3b - Aravind's algorithm and improvements.md",
"Concurrent Systems/notes/3a - Hardware primitives & Lamport Bakery algorithm.md", "Concurrent Systems/notes/3a - Hardware primitives & Lamport Bakery algorithm.md",
@ -227,7 +228,6 @@
"Concurrent Systems/slides/class 9.pdf", "Concurrent Systems/slides/class 9.pdf",
"Concurrent Systems/slides/class 10.pdf", "Concurrent Systems/slides/class 10.pdf",
"Concurrent Systems/test", "Concurrent Systems/test",
"Concurrent Systems/notes/10 - Implementing Consensus.md",
"HCIW/slides/Tangible User Interfaces.pdf", "HCIW/slides/Tangible User Interfaces.pdf",
"Concurrent Systems/notes/images/Pasted image 20250401083747.png", "Concurrent Systems/notes/images/Pasted image 20250401083747.png",
"Concurrent Systems/notes/images/Pasted image 20250401092557.png", "Concurrent Systems/notes/images/Pasted image 20250401092557.png",

View file

@ -34,3 +34,37 @@ end_write() :=
GLOB_MUTEX.up() GLOB_MUTEX.up()
return return
``` ```
```
monitor RW_READERS :=
AR, WR, AW, WW, LASTW init at 0
condition CR, CW
operation begin_read() :=
if WW + AW != 0 then
CR.wait()
CR.signal()
AR++
operation end_read() :=
AR--
if AR = 0 then
CW.signal()
operation begin_write() :=
WW++
LASTW <- i
CW.signal() # wakes eventually other waiting writers *they will return false*
if (AR + AW != 0) then
CW.wait()
if LASTW
AW++
WW--
operation end_write() :=
AW--
if WW > 0 then
CW.signal()
else
CR.signal()
```