vault backup: 2025-03-12 11:44:27

This commit is contained in:
Marco Realacci 2025-03-12 11:44:27 +01:00
parent 5df57ffe73
commit c9d53c7954

View file

@ -205,7 +205,8 @@ end_write() :=
##### 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() :=
PRIO_MUTEX.down()
@ -217,5 +218,27 @@ begin_read() :=
PRIO_MUTEX.up()
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