Class RWLock
source code
Synchronization object used in a solution of so-called second
readers-writers problem. In this problem, many readers can simultaneously
access a share, and a writer has an exclusive access to this share.
Additionally, the following constraints should be met:
-
no reader should be kept waiting if the share is currently opened for
reading unless a writer is also waiting for the share,
-
no writer should be kept waiting for the share longer than absolutely
necessary.
The implementation is based on [1, secs. 4.2.2, 4.2.6, 4.2.7] with a
modification -- adding an additional lock
(self.__readers_queue) -- in accordance with [2].
Sources:
-
A.B. Downey: "The little book of semaphores", Version
2.1.5, 2008
-
P.J. Courtois, F. Heymans, D.L. Parnas: "Concurrent Control with
'Readers' and 'Writers'", Communications of the ACM, 1971 (via
[3])
-
http://en.wikipedia.org/wiki/Readers-writers_problem
|
|
__readers_queue
A lock giving an even higher priority to the writer in certain cases
(see [2] for a discussion)
|