Reader-Writers Problem
The readers/writers problem is defined as follows: There is a data area shared among a number of processes. The data area could be a file, a block of main memory, or even a bank of processor registers. There are a number of processes that only read the data area (readers) and a number that only write to the data area (writers).
Must satisfy the following conditions:
- Any number of readers may simultaneously read the file
- Only one writer at a time may write to the file
- If a writer is writing in the file, no reader may read it
Readers Have Priority
Since readers have priority. Once a single reader has begun to access the data area, it is possible for readers to retain control of the data area as long as there is at least one reader in the act of reading. Therefore, writers are subject to Starvation.
Writers Have Priority
Alternative solution giving writers priority and implemented using Message Passing is shown bellow in Figure 5.24: