vault backup: 2025-04-05 00:05:56
This commit is contained in:
parent
a99d09af0c
commit
47b74f3eec
4 changed files with 6 additions and 6 deletions
6
.obsidian/workspace.json
vendored
6
.obsidian/workspace.json
vendored
|
@ -13,12 +13,12 @@
|
||||||
"state": {
|
"state": {
|
||||||
"type": "markdown",
|
"type": "markdown",
|
||||||
"state": {
|
"state": {
|
||||||
"file": "Concurrent Systems/notes/1b - Peterson algorithm.md",
|
"file": "Concurrent Systems/notes/2b - Round Robin algorithm.md",
|
||||||
"mode": "source",
|
"mode": "source",
|
||||||
"source": false
|
"source": false
|
||||||
},
|
},
|
||||||
"icon": "lucide-file",
|
"icon": "lucide-file",
|
||||||
"title": "1b - Peterson algorithm"
|
"title": "2b - Round Robin algorithm"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -191,8 +191,8 @@
|
||||||
},
|
},
|
||||||
"active": "7c5b0ca6f7687800",
|
"active": "7c5b0ca6f7687800",
|
||||||
"lastOpenFiles": [
|
"lastOpenFiles": [
|
||||||
"Concurrent Systems/notes/images/Pasted image 20250405000438.png",
|
|
||||||
"Concurrent Systems/notes/1b - Peterson algorithm.md",
|
"Concurrent Systems/notes/1b - Peterson algorithm.md",
|
||||||
|
"Concurrent Systems/notes/images/Pasted image 20250405000438.png",
|
||||||
"Pasted image 20250405000428.png",
|
"Pasted image 20250405000428.png",
|
||||||
"Concurrent Systems/notes/3b - Aravind's algorithm and improvements.md",
|
"Concurrent Systems/notes/3b - Aravind's algorithm and improvements.md",
|
||||||
"Concurrent Systems/notes/4 - Semaphores.md",
|
"Concurrent Systems/notes/4 - Semaphores.md",
|
||||||
|
|
|
@ -140,7 +140,7 @@ Easy to generalize to k-MUTEX.
|
||||||
|
|
||||||
Peterson's algorithm cost $O(n^2)$
|
Peterson's algorithm cost $O(n^2)$
|
||||||
A first way to reduce this cost is by using a tournament of MUTEX between pairs of processes:
|
A first way to reduce this cost is by using a tournament of MUTEX between pairs of processes:
|
||||||

|

|
||||||
|
|
||||||
Of course this is a binary tree, and the height of a binary tree is logaritmic to the number of leaves. A process then wins after $\lceil \log_{2}n \rceil$ competitions $\to O(\log n)$ cost.
|
Of course this is a binary tree, and the height of a binary tree is logaritmic to the number of leaves. A process then wins after $\lceil \log_{2}n \rceil$ competitions $\to O(\log n)$ cost.
|
||||||
|
|
||||||
|
|
|
@ -180,7 +180,7 @@ producer A:
|
||||||
- so producer A will write at `BUF[0]`
|
- so producer A will write at `BUF[0]`
|
||||||
- but wait! Consumer B is still reading there
|
- but wait! Consumer B is still reading there
|
||||||
- **Producer A doesn't give a fuck.**
|
- **Producer A doesn't give a fuck.**
|
||||||

|
![]()
|
||||||
*don't be like Producer A, be more like Bob, who always scans EMPTY before!*
|
*don't be like Producer A, be more like Bob, who always scans EMPTY before!*
|
||||||
|
|
||||||
So the issue here is that producers just assume that IN is the first available slot. But it its not necessarily the case.
|
So the issue here is that producers just assume that IN is the first available slot. But it its not necessarily the case.
|
||||||
|
|
|
@ -3,7 +3,7 @@ The first real practical example of a concurrent system.
|
||||||
- one chopstick between each pair of philosophers
|
- one chopstick between each pair of philosophers
|
||||||
- a philosophers must pick up its two nearest chopsticks in order to eat
|
- a philosophers must pick up its two nearest chopsticks in order to eat
|
||||||
- a philosopher must pick up first one chopstick, then the second one, not both at once
|
- a philosopher must pick up first one chopstick, then the second one, not both at once
|
||||||

|
![]()
|
||||||
|
|
||||||
**PROBLEM:** *Devise a deadlock-free algorithm for allocating these limited resources (chopsticks) among several processes (philosophers).*
|
**PROBLEM:** *Devise a deadlock-free algorithm for allocating these limited resources (chopsticks) among several processes (philosophers).*
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue