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
|
@ -153,4 +153,30 @@ conc_write() :=
|
|||
|
||||
##### Weak priority to Readers
|
||||
- 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…
Add table
Add a link
Reference in a new issue