vault backup: 2025-03-12 12:19:27

This commit is contained in:
Marco Realacci 2025-03-12 12:19:27 +01:00
parent 5dffa6402e
commit a6939cfeb2
3 changed files with 17 additions and 8 deletions

View file

@ -34,9 +34,9 @@
"type": "pdf",
"state": {
"file": "Concurrent Systems/slides/class 4.pdf",
"page": 10,
"page": 6,
"left": -23,
"top": 122,
"top": 126,
"zoom": 0.652019002375297
},
"icon": "lucide-file-text",
@ -217,6 +217,7 @@
},
"active": "6edd4157a160e462",
"lastOpenFiles": [
"Concurrent Systems/notes/images/Pasted image 20250312121828.png",
"Concurrent Systems/slides/class 4.pdf",
"Concurrent Systems/notes/4 - Semaphores.md",
"Concurrent Systems/notes/3a - Hardware primitives & Lamport Bakery algorithm.md",

View file

@ -162,18 +162,26 @@ producer A:
- ...
- writes at BUF[n], so IN becomes 0
**Now there are no free slots.**
consumer A:
- starts reading BUF[0], now OUT is 1
- it is a sloooooooooow consumer
consumer B:
- finds OUT at 1
- sets OUT at 2 and starts reading
- finishes reading
- finds OUT at 1, sets OUT at 2 and starts reading
- finishes reading (before consumer A)
- sets EMPTY[1] <- tt
- calls `FREE.up()`
consumer A:
- finishes reading (finally)
- sets EMPTY[0] <- tt
producer A:
- as consumer B called `FREE.up()`, the producer can finally produce
- remember, IN is set to 0!
- so producer A will write at `BUF[0]`
- but wait! Consumer B is still reading there
- **Producer A doesn't give a fuck.**
![[Pasted image 20250312121828.png|200]]
*don't be like Producer A, be more like Bob*

Binary file not shown.

After

Width:  |  Height:  |  Size: 713 KiB