reference:
compare_exchange_weak / compare_exchange_strong
compare_exchange_strong; no spuriously fail
compare_exchange_weak; spuriously fail due to using timed lock; compare_exchange_weak is useful inside a loop;
reference:
compare_exchange_weak / compare_exchange_strong
compare_exchange_strong; no spuriously fail
compare_exchange_weak; spuriously fail due to using timed lock; compare_exchange_weak is useful inside a loop;
Reference:
std::shared_mutex
pthread_rwlock_init
stackoverflow response:
https://stackoverflow.com/a/57709957
https://stackoverflow.com/a/2190271
C++17's std::shared_mutex on linux might using pthread_rwlock_t underneath, thus in order to tweak
the behavior of write starvation, set PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP in the pthread_rwlock_init call's pthread_rwlockattr_t is necessary.
For those not using pthread_rwlock_t, std::shared_mutex should rely on linux kernel's scheduler, which is fair, avoid either write/read starvation.
Here's how Go handles stavation:
http://vsdmars.blogspot.com/2021/03/go-methods-for-lock-starvation-barging.html