RWLock vs Mutex when multiple readers

603 Views Asked by At

I am implementing a C++ multithreading app and I have a lot many readers than writers (ratio 30:1 at least) on some variables and I thought of using RWLocks(maybe pthread_rwlock) instead of Mutexes(std::mutex), because they seem much suitable for many readers.

What I read:
https://en.wikipedia.org/wiki/Readers%E2%80%93writer_lock
https://www.arangodb.com/2015/02/comparing-atomic-mutex-rwlocks/
https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/concurrent/locks/ReadWriteLock.html (java but I think that the principles are the same)

But it seems that custom implementations of RWLock contains internally at least a mutex, so why use RWLock?

0

There are 0 best solutions below