vault backup: 2025-03-12 11:44:27
This commit is contained in:
parent
5df57ffe73
commit
c9d53c7954
1 changed files with 26 additions and 3 deletions
|
@ -205,7 +205,8 @@ end_write() :=
|
||||||
|
|
||||||
##### Weak priority to Writers
|
##### Weak priority to Writers
|
||||||
```
|
```
|
||||||
GLOB_MUTEX, PRIO_MUTEX, R_MUTEX and W_MUTEX semaphores init. at 1 R and W shared registers init. at 0
|
GLOB_MUTEX, PRIO_MUTEX (to prioritize the writers), R_MUTEX and W_MUTEX semaphores init. at 1
|
||||||
|
R and W shared registers init. at 0
|
||||||
|
|
||||||
begin_read() :=
|
begin_read() :=
|
||||||
PRIO_MUTEX.down()
|
PRIO_MUTEX.down()
|
||||||
|
@ -217,5 +218,27 @@ begin_read() :=
|
||||||
PRIO_MUTEX.up()
|
PRIO_MUTEX.up()
|
||||||
return
|
return
|
||||||
|
|
||||||
end_read() :=
|
end_read() := # like weak priority to readers
|
||||||
|
R_MUTEX.down()
|
||||||
|
R--
|
||||||
|
if R = 0 then GLOB_MUTEX.up()
|
||||||
|
R_MUTEX.up()
|
||||||
|
return
|
||||||
|
|
||||||
|
def begin_write() :=
|
||||||
|
W_MUTEX.down()
|
||||||
|
W++
|
||||||
|
if W = 1 then
|
||||||
|
PRIO_MUTEX.down()
|
||||||
|
W_MUTEX.up()
|
||||||
|
GLOB_MUTEX.down()
|
||||||
|
return
|
||||||
|
|
||||||
|
def end_write() :=
|
||||||
|
GLOB_MUTEX.up()
|
||||||
|
W_MUTEX.down()
|
||||||
|
W--
|
||||||
|
if W = 0 then
|
||||||
|
PRIO_MUTEX.up()
|
||||||
|
W_MUTEX.up()
|
||||||
|
return
|
Loading…
Reference in a new issue