vault backup: 2025-03-12 10:49:27
This commit is contained in:
parent
6547be1a32
commit
484cb712c6
2 changed files with 20 additions and 4 deletions
8
.obsidian/workspace.json
vendored
8
.obsidian/workspace.json
vendored
|
@ -34,9 +34,9 @@
|
|||
"type": "pdf",
|
||||
"state": {
|
||||
"file": "Concurrent Systems/slides/class 4.pdf",
|
||||
"page": 3,
|
||||
"page": 4,
|
||||
"left": -23,
|
||||
"top": 298,
|
||||
"top": 342,
|
||||
"zoom": 0.652019002375297
|
||||
},
|
||||
"icon": "lucide-file-text",
|
||||
|
@ -217,10 +217,10 @@
|
|||
},
|
||||
"active": "6edd4157a160e462",
|
||||
"lastOpenFiles": [
|
||||
"Concurrent Systems/slides/class 4.pdf",
|
||||
"Concurrent Systems/notes/4 - Semaphores.md",
|
||||
"Concurrent Systems/notes/3a - Hardware primitives & Lamport Bakery algorithm.md",
|
||||
"Concurrent Systems/notes/3b - Aravind's algorithm and improvements.md",
|
||||
"Concurrent Systems/notes/4 - Semaphores.md",
|
||||
"Concurrent Systems/slides/class 4.pdf",
|
||||
"Concurrent Systems/notes/images/Pasted image 20250310172134.png",
|
||||
"Concurrent Systems/notes/1b - Peterson algorithm.md",
|
||||
"Concurrent Systems/slides/class 3.pdf",
|
||||
|
|
|
@ -48,11 +48,27 @@ S.down() :=
|
|||
if S.counter < 0 then
|
||||
enter into S.queue
|
||||
S.t <- 0
|
||||
Enable interrupts
|
||||
SUSPEND
|
||||
else
|
||||
S.t <- 0
|
||||
Enable interrupts
|
||||
return
|
||||
|
||||
S.up() :=
|
||||
Disable interrupts
|
||||
wait S.t.test&set() = 0
|
||||
S.counter++
|
||||
if S.counter <= 0 then
|
||||
activate a proc from S.queue
|
||||
S.t <- 0
|
||||
Enable interrupts
|
||||
return
|
||||
```
|
||||
Same as before but we use test&set to actually ensure MUTEX (of course we could have used any other hardware MUTEX implementation seen so far).
|
||||
|
||||
#### (Single) Producer/Consumer
|
||||
It's a shared FIFO buffer of size k.
|
||||
- `BUF[0,…,k-1]`: generic registers (not even safe) accessed in MUTEX
|
||||
- `IN/OUT` : two variables pointing to locations in `BUF` to (circularly) insert/remove items, both initialized at 0
|
||||
- `FREE/BUSY`: two semaphores that count thew number of free/busy cells of BUF, initialized at k and 0 respectively.
|
Loading…
Reference in a new issue