Mutual Exclusion vs Read-Write Separation
A mutex ensures only one thread accesses a resource at a time. Multiple threads waiting on the mutex block until the current holder releases it. This is simple and safe for any access pattern, but it serializes readers and writers.
A read-write lock (RWLock) distinguishes read access (which doesn't mutate state) from write access (which does). Multiple readers can hold the lock simultaneously; only one writer can hold it, and then no readers. If your workload is predominantly reads with occasional writes, an RWLock yields better throughput than a mutex by allowing read parallelism.
Choosing by Workload
Use a mutex when the code is simple or writes are common. Mutex code is straightforward: lock, modify, unlock. No complexity around reader vs writer fairness.
Use an RWLock when reads vastly outnumber writes. For example, a cache that is read a thousand times per write benefits hugely from RWLock, because all thousand readers proceed concurrently. If reads and writes are balanced, the overhead of RWLock (tracking reader count, writer waiting) can exceed the benefit of parallelism. Workload measurement is key. Modern lock-free data structures (atomic operations, compare-and-swap) can outperform both in contended scenarios, but are harder to reason about.