vault backup: 2025-04-03 00:10:03
This commit is contained in:
parent
90e5cc1e91
commit
018560c352
2 changed files with 38 additions and 3 deletions
6
.obsidian/workspace.json
vendored
6
.obsidian/workspace.json
vendored
|
@ -13,12 +13,12 @@
|
||||||
"state": {
|
"state": {
|
||||||
"type": "markdown",
|
"type": "markdown",
|
||||||
"state": {
|
"state": {
|
||||||
"file": "Concurrent Systems/notes/4b - Monitors.md",
|
"file": "Concurrent Systems/test/Untitled.md",
|
||||||
"mode": "source",
|
"mode": "source",
|
||||||
"source": false
|
"source": false
|
||||||
},
|
},
|
||||||
"icon": "lucide-file",
|
"icon": "lucide-file",
|
||||||
"title": "4b - Monitors"
|
"title": "Untitled"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -206,8 +206,8 @@
|
||||||
},
|
},
|
||||||
"active": "7c5b0ca6f7687800",
|
"active": "7c5b0ca6f7687800",
|
||||||
"lastOpenFiles": [
|
"lastOpenFiles": [
|
||||||
"Concurrent Systems/notes/4 - Semaphores.md",
|
|
||||||
"Concurrent Systems/notes/4b - Monitors.md",
|
"Concurrent Systems/notes/4b - Monitors.md",
|
||||||
|
"Concurrent Systems/notes/4 - Semaphores.md",
|
||||||
"Concurrent Systems/notes/5 - Software Transactional Memory.md",
|
"Concurrent Systems/notes/5 - Software Transactional Memory.md",
|
||||||
"Concurrent Systems/test/Untitled.md",
|
"Concurrent Systems/test/Untitled.md",
|
||||||
"Concurrent Systems/notes/4c - Dining Philosophers.md",
|
"Concurrent Systems/notes/4c - Dining Philosophers.md",
|
||||||
|
|
|
@ -34,3 +34,38 @@ end_write() :=
|
||||||
GLOB_MUTEX.up()
|
GLOB_MUTEX.up()
|
||||||
return
|
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()
|
||||||
|
```
|
Loading…
Add table
Add a link
Reference in a new issue