Search code examples
concurrencynonsequential

Is "readers-writers" just "producer–consumer" with multiple consumers?


see thread title: Is "readers-writers problem" just "producer–consumers problem" with multiple consumers? Intuitively I would say no, but I have no way to explain it and also could see this question be affirmed.


Solution

  • Readers-Writers implies that the Readers do not modify the underlying state, thus many can simultaneously access it; however because a Writer can freely modify the state, no Reader can simultaneously access it.

    Producer-Consumer is a common synchronization problem with two accessors: one that replenishes a resource and one that consumes it. You can’t have multiple producers or consumers simultaneously accessing it. The confusion may arise because there are many (restricted) implementations which use busy-waiting (er, transactional memory) to wrestle better performance out of this patten.