4

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.

user1994928
  • 43
  • 1
  • 4

2 Answers2

6

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.

mevets
  • 10,070
  • 1
  • 21
  • 33
0

Producer: produces a message. Also, he has to read the queue pointers to determine where to write the next item and to determine if the buffer is full.

Consumer: The consumer is not just a reader, because it must adjust the queue pointers to show that it has removed a unit from the buffer.

Writer: Writers are processes which exclude all the others when writing a file, readers and writers alike.

Reader: Readers are processes which are not required to exclude one another. Any number of readers may simultaneously read the file.

Reference : "Operating Systems" William Stallings

imanousar
  • 1
  • 2