vault backup: 2025-03-17 10:04:23

This commit is contained in:
Marco Realacci 2025-03-17 10:04:23 +01:00
parent e9f44190a2
commit 8e1ea33ab8
3 changed files with 18 additions and 11 deletions

View file

@ -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.

View 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