Readers / Writers Problem
Readers/Writers problem models access to a database. It is
acceptable to have multiple processes reading the database at the same
time, but if one process is updating (writing) the database, no other
processes may have access to the database, no even readers.
P.J. Corbato, F. Heymans, and D.L. Parans, Concurrent Control with Readers and
Writers, Commun. of the ACM, vol. 10,
pp. 667-668. Oct. 1971
Jean Bacon, Conncurrent systems Operating Systems, Database and
Distributed Systems: An integrated Approach, 2nd Edition,
Addison-Wesley, pp. 286-289
Andrew S. Tanenbaum and Albert S. Woodhull, Operating Systems: Design and
Implementation, 2nd Edition, Prentice-Hall, pp. 77-80
Bradford Nichols, Dick Buttlar and Jacqueline Proulx Farrell, Pthreads
Programming, O'Reilly & Associates, Inc., pp. 84-89
Solution 1 use at your own risk
We demand of our solution that no reader be kept waiting unless a
writer has already obtained permission to use the resources; i.e. no
reader should wait simply because a writer is waiting for other
readers to finish. It is possible that a writer could wait indefinitly
while a stream of readers arrived.
Solution 2 use at your own risk
We give priority to writers in which once a writer is ready to write,
he performs his "write" as soon as possible. Readers are allowed to
wait indefinitely while a stream of writers is working.
Solution 3 use at your own risk
When a reader arrives and a writer is waiting, the reader is suspended
behind the writer instead of being admitted immediately. In this way,
a writer has to wait for readers that were active when it arrived to
finish but does not to wait for readers that came along after it.