Why can only one updated lock with shared locks be saved

The acceleration documentation for updatable and shared locks says that when sharing shared locks, only one other thread can get an updatable lock. In order for other threads to try to obtain an updated lock when they lock together (s) together with an updated lock, they will be blocked.

Is there some kind of dead-end probability that I am missing when more than one thread receives updated locks along with one (or several separate locks)? Or is it just a logical requirement (so “shouldn't do this”)?

Please note that I am not talking about exclusively blocked states. Only updated locked state. If the lock being updated is held together with other shared locks, it is essentially a READ lock. Then why can't two updated locks be held?

+4
source share
1 answer

Is there some kind of deadlock probability that I am missing when more than one thread gets updated locks

TL DR Yes there is.

together with one (or more than one common lock)

. - .


, . :

  • ( ),
  • .
  • .

, ( )/ (), :

  • Writer
  • , - .

, check-write . , :

  • Writer
  • .
  • Writer
  • , .

3. 4. - - . , . , .

, , , , , ! , , , . , undefined, , . , , , , - . , , .


- ():

  • Writer
  • Writer , , ( , ).

, . , , . , , .

, , , , .

+4

Source: https://habr.com/ru/post/1649485/


All Articles