piątek, 28 sierpnia 2015

upgradeable RW-locks - no, no

Never to be forgotten - upgradeable RW-locks always lead to deadlock.
I.e. when reader upgrades to writer without first leaving read lock, then other tread doing same lead to deadlock - no one moves back - deadlock.
Therefore:
- do not think on upgradeable RW-locks,
- if do so, then try-upgrade() function might be good approach, or
- deadlock detection, or
- 3rd user type - beside reader and writer - upgreadeableReader (like EnterUpgradeableReadLock from .NET). There can be only one upgreadeableReader (mutually exclusive). Normal readers cannot upgrade, therefore it is certain that only one user-reader will try to upgrade.

Brak komentarzy:

Prześlij komentarz