vault backup: 2025-03-17 10:04:23
This commit is contained in:
parent
e9f44190a2
commit
8e1ea33ab8
3 changed files with 18 additions and 11 deletions
11
.obsidian/workspace.json
vendored
11
.obsidian/workspace.json
vendored
|
@ -13,12 +13,12 @@
|
||||||
"state": {
|
"state": {
|
||||||
"type": "markdown",
|
"type": "markdown",
|
||||||
"state": {
|
"state": {
|
||||||
"file": "Concurrent Systems/notes/4b -.md",
|
"file": "Concurrent Systems/notes/4c - Dining Philosophers.md",
|
||||||
"mode": "source",
|
"mode": "source",
|
||||||
"source": false
|
"source": false
|
||||||
},
|
},
|
||||||
"icon": "lucide-file",
|
"icon": "lucide-file",
|
||||||
"title": "4b -"
|
"title": "4c - Dining Philosophers"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -34,9 +34,9 @@
|
||||||
"type": "pdf",
|
"type": "pdf",
|
||||||
"state": {
|
"state": {
|
||||||
"file": "Concurrent Systems/slides/class 4.pdf",
|
"file": "Concurrent Systems/slides/class 4.pdf",
|
||||||
"page": 16,
|
"page": 17,
|
||||||
"left": -27,
|
"left": -27,
|
||||||
"top": 130,
|
"top": 78,
|
||||||
"zoom": 0.5754156769596199
|
"zoom": 0.5754156769596199
|
||||||
},
|
},
|
||||||
"icon": "lucide-file-text",
|
"icon": "lucide-file-text",
|
||||||
|
@ -218,8 +218,9 @@
|
||||||
},
|
},
|
||||||
"active": "6edd4157a160e462",
|
"active": "6edd4157a160e462",
|
||||||
"lastOpenFiles": [
|
"lastOpenFiles": [
|
||||||
|
"Concurrent Systems/notes/4b - Monitors.md",
|
||||||
|
"Concurrent Systems/notes/4c - Dining Philosophers.md",
|
||||||
"Concurrent Systems/slides/class 4.pdf",
|
"Concurrent Systems/slides/class 4.pdf",
|
||||||
"Concurrent Systems/notes/4b -.md",
|
|
||||||
"Concurrent Systems/slides/class 5.pdf",
|
"Concurrent Systems/slides/class 5.pdf",
|
||||||
"HCIW/slides/4 HUI2016-6-forcefeedback.pdf",
|
"HCIW/slides/4 HUI2016-6-forcefeedback.pdf",
|
||||||
"HCIW/slides/3b Haptic slides.pdf",
|
"HCIW/slides/3b Haptic slides.pdf",
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
### Monitors
|
|
||||||
Semaphores are hard to use in practice because quite low level Monitors provide an easier definition of concurrent objects at the level of Prog. Lang.
|
Semaphores are hard to use in practice because quite low level Monitors provide an easier definition of concurrent objects at the level of Prog. Lang.
|
||||||
|
|
||||||
It guarantees mutual exclusion.
|
It guarantees mutual exclusion.
|
||||||
|
@ -109,7 +108,7 @@ operation end_read() :=
|
||||||
|
|
||||||
operation begin_write() :=
|
operation begin_write() :=
|
||||||
WW++
|
WW++
|
||||||
if (AR+AW != 0) then
|
if (AR + AW != 0) then
|
||||||
CW.wait()
|
CW.wait()
|
||||||
AW++
|
AW++
|
||||||
WW--
|
WW--
|
||||||
|
@ -145,15 +144,16 @@ operation end_read() :=
|
||||||
|
|
||||||
operation begin_write() :=
|
operation begin_write() :=
|
||||||
WW++
|
WW++
|
||||||
if (AR+AW != 0) then
|
if (AR + AW != 0) then
|
||||||
CW.wait()
|
CW.wait()
|
||||||
AW++
|
AW++
|
||||||
WW--
|
WW--
|
||||||
|
|
||||||
operation end_write() :=
|
operation end_write() :=
|
||||||
AW--
|
AW--
|
||||||
if WW > 0 then
|
if WR > 0 then
|
||||||
CW.signal()
|
|
||||||
else
|
|
||||||
CR.signal()
|
CR.signal()
|
||||||
|
else
|
||||||
|
CW.signal()
|
||||||
```
|
```
|
||||||
|
This way nobody gets starved forever.
|
6
Concurrent Systems/notes/4c - Dining Philosophers.md
Normal file
6
Concurrent Systems/notes/4c - Dining Philosophers.md
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
The first real practical example of a concurrent system.
|
||||||
|
|
||||||
|
- $N$ philosophers seated around a circular table
|
||||||
|
- one chopstick between each pair of philosophers
|
||||||
|
- a philosophers must pick up its two nearest chopsticks in order to eat
|
||||||
|
- a philosoph
|
Loading…
Add table
Add a link
Reference in a new issue