4.5. Advanced Synchronization: The Readers/Writers Problem

Even complex synchronization problems can be handled with variants of the techniques you have already encountered in this chapter. As an example, we'll look at a classical synchronization problem known as the readers/writers problem.

The readers/writers problem goes like this: A collection of processes need to share access to some resource. Some processes are “readers” that need to read the current state of the resource, while others are “writers” that need to update its state. Two rules must be followed:

  1. The resource may be accessed by multiple readers or by a single writer at a given time, but not both.

  2. No read request or write request may be postponed indefinitely.

According to the ...

Get JavaSpaces™ Principles, Patterns, and Practice now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.