vault backup: 2025-03-17 09:59:23
This commit is contained in:
parent
8a87dd23d7
commit
e9f44190a2
2 changed files with 71 additions and 3 deletions
4
.obsidian/workspace.json
vendored
4
.obsidian/workspace.json
vendored
|
@ -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": 14,
|
"page": 16,
|
||||||
"left": -27,
|
"left": -27,
|
||||||
"top": 94,
|
"top": 130,
|
||||||
"zoom": 0.5754156769596199
|
"zoom": 0.5754156769596199
|
||||||
},
|
},
|
||||||
"icon": "lucide-file-text",
|
"icon": "lucide-file-text",
|
||||||
|
|
|
@ -88,4 +88,72 @@ operation end_write() :=
|
||||||
else
|
else
|
||||||
CW.signal()
|
CW.signal()
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Readers/Writers problem, strong priority to Writers
|
||||||
|
```
|
||||||
|
monitor RW_READERS :=
|
||||||
|
AR, WR, AW, WW init at 0
|
||||||
|
condition CR, CW
|
||||||
|
|
||||||
|
operation begin_read() :=
|
||||||
|
if WW + AW != 0 then
|
||||||
|
CR.wait()
|
||||||
|
CR.signal()
|
||||||
|
AR++
|
||||||
|
|
||||||
|
operation end_read() :=
|
||||||
|
AR--
|
||||||
|
if AR = 0 then
|
||||||
|
CW.signal()
|
||||||
|
|
||||||
|
operation begin_write() :=
|
||||||
|
WW++
|
||||||
|
if (AR+AW != 0) then
|
||||||
|
CW.wait()
|
||||||
|
AW++
|
||||||
|
WW--
|
||||||
|
|
||||||
|
operation end_write() :=
|
||||||
|
AW--
|
||||||
|
if WW > 0 then
|
||||||
|
CW.signal()
|
||||||
|
else
|
||||||
|
CR.signal()
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Readers/Writers problem, a fair solution
|
||||||
|
- after a write, all waiting readers are enabled
|
||||||
|
- during a read, new readers must wait if writers are waiting
|
||||||
|
```
|
||||||
|
monitor RW_READERS :=
|
||||||
|
AR, WR, AW, WW init at 0
|
||||||
|
condition CR, CW
|
||||||
|
|
||||||
|
operation begin_read() :=
|
||||||
|
WR++
|
||||||
|
if WW + AW != 0 then
|
||||||
|
CR.wait()
|
||||||
|
CR.signal()
|
||||||
|
AR++
|
||||||
|
WR--
|
||||||
|
|
||||||
|
operation end_read() :=
|
||||||
|
AR--
|
||||||
|
if AR = 0 then
|
||||||
|
CW.signal()
|
||||||
|
|
||||||
|
operation begin_write() :=
|
||||||
|
WW++
|
||||||
|
if (AR+AW != 0) then
|
||||||
|
CW.wait()
|
||||||
|
AW++
|
||||||
|
WW--
|
||||||
|
|
||||||
|
operation end_write() :=
|
||||||
|
AW--
|
||||||
|
if WW > 0 then
|
||||||
|
CW.signal()
|
||||||
|
else
|
||||||
|
CR.signal()
|
||||||
|
```
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue