vault backup: 2025-03-12 11:24:27
This commit is contained in:
parent
7ffffd2d0f
commit
ec1b4706d8
2 changed files with 28 additions and 2 deletions
2
.obsidian/workspace.json
vendored
2
.obsidian/workspace.json
vendored
|
@ -36,7 +36,7 @@
|
||||||
"file": "Concurrent Systems/slides/class 4.pdf",
|
"file": "Concurrent Systems/slides/class 4.pdf",
|
||||||
"page": 8,
|
"page": 8,
|
||||||
"left": -23,
|
"left": -23,
|
||||||
"top": 421,
|
"top": 187,
|
||||||
"zoom": 0.652019002375297
|
"zoom": 0.652019002375297
|
||||||
},
|
},
|
||||||
"icon": "lucide-file-text",
|
"icon": "lucide-file-text",
|
||||||
|
|
|
@ -154,3 +154,29 @@ conc_write() :=
|
||||||
##### Weak priority to Readers
|
##### Weak priority to Readers
|
||||||
- If a reader arrives during a read, it can surpass possible writers already suspended (risk of starvation for the writes)
|
- If a reader arrives during a read, it can surpass possible writers already suspended (risk of starvation for the writes)
|
||||||
- When a writer terminates, it activates the first suspended process, irrispectively of whether it is a reader or a writer (so, the priority to readers is said «weak»)
|
- When a writer terminates, it activates the first suspended process, irrispectively of whether it is a reader or a writer (so, the priority to readers is said «weak»)
|
||||||
|
|
||||||
|
```
|
||||||
|
GLOB_MUTEX and R_MUTEX semaphores init. at 1
|
||||||
|
R a shared register init. at 0
|
||||||
|
|
||||||
|
begin_read() :=
|
||||||
|
R_MUTEX.down()
|
||||||
|
R++ # currently active readers
|
||||||
|
if R = 1 then GLOB_MUTEX.down()
|
||||||
|
R_MUTEX.up()
|
||||||
|
return
|
||||||
|
|
||||||
|
end_read() :=
|
||||||
|
R_MUTEX.down()
|
||||||
|
R--
|
||||||
|
if R = 0 then GLOB_MUTEX.up()
|
||||||
|
R_MUTEX.up()
|
||||||
|
return
|
||||||
|
|
||||||
|
begin_write() :=
|
||||||
|
GLOB_MUTEX.down()
|
||||||
|
return
|
||||||
|
|
||||||
|
end_write() :=
|
||||||
|
GLOB_MUTEX.up()
|
||||||
|
return
|
||||||
|
|
Loading…
Reference in a new issue