All the locking mechanisms that I have discussed so far were designed for symmetric scenarios. In all examples, they were synchronizing multiple threads that were all doing (more or less) the same work. This is, however, not the only type of shared data access we can encounter.
Another frequent situation that occurs in multithreaded applications is when multiple threads are just reading from the shared data without doing any modifications. That by itself would not require any locking at all, except that from time to time, the data has to be modified. To do that, we somehow have to stop the reading threads. We must also, as before, prevent two writers from working on the data at the same time.
In such a situation, we need a synchronization mechanism that allows multiple readers to share the resource while also allowing one writer to...