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", "type": "pdf",
"state": { "state": {
"file": "Concurrent Systems/slides/class 4.pdf", "file": "Concurrent Systems/slides/class 4.pdf",
"page": 10, "page": 6,
"left": -23, "left": -23,
"top": 122, "top": 126,
"zoom": 0.652019002375297 "zoom": 0.652019002375297
}, },
"icon": "lucide-file-text", "icon": "lucide-file-text",
@ -217,6 +217,7 @@
}, },
"active": "6edd4157a160e462", "active": "6edd4157a160e462",
"lastOpenFiles": [ "lastOpenFiles": [
"Concurrent Systems/notes/images/Pasted image 20250312121828.png",
"Concurrent Systems/slides/class 4.pdf", "Concurrent Systems/slides/class 4.pdf",
"Concurrent Systems/notes/4 - Semaphores.md", "Concurrent Systems/notes/4 - Semaphores.md",
"Concurrent Systems/notes/3a - Hardware primitives & Lamport Bakery algorithm.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 - writes at BUF[n], so IN becomes 0
**Now there are no free slots.**
consumer A: consumer A:
- starts reading BUF[0], now OUT is 1 - starts reading BUF[0], now OUT is 1
- it is a sloooooooooow consumer
consumer B: consumer B:
- finds OUT at 1 - finds OUT at 1, sets OUT at 2 and starts reading
- sets OUT at 2 and starts reading - finishes reading (before consumer A)
- finishes reading
- sets EMPTY[1] <- tt - sets EMPTY[1] <- tt
- calls `FREE.up()`
consumer A: producer A:
- finishes reading (finally) - as consumer B called `FREE.up()`, the producer can finally produce
- sets EMPTY[0] <- tt - 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