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
|
@ -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.
|
||||
|
||||
It guarantees mutual exclusion.
|
||||
|
@ -109,7 +108,7 @@ operation end_read() :=
|
|||
|
||||
operation begin_write() :=
|
||||
WW++
|
||||
if (AR+AW != 0) then
|
||||
if (AR + AW != 0) then
|
||||
CW.wait()
|
||||
AW++
|
||||
WW--
|
||||
|
@ -145,15 +144,16 @@ operation end_read() :=
|
|||
|
||||
operation begin_write() :=
|
||||
WW++
|
||||
if (AR+AW != 0) then
|
||||
if (AR + AW != 0) then
|
||||
CW.wait()
|
||||
AW++
|
||||
WW--
|
||||
|
||||
operation end_write() :=
|
||||
AW--
|
||||
if WW > 0 then
|
||||
CW.signal()
|
||||
else
|
||||
if WR > 0 then
|
||||
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