rmlock question..

Darren Reed darrenr at freebsd.org
Mon Nov 26 09:48:16 PST 2007

Stephan Uphoff wrote:
> Julian Elischer wrote:
>> Julian Elischer wrote:
>>> If I make an exclusive rmlock request on an rmlock that has a busy 
>>> set of readers coming and going, do new readers wait for me to get
>>> my turn, or do I have to wait for a moment where there are no more 
>>> readers before I get a go?
>> in fact if the requests are of the order
>> reader, reader, writer, reader, reader, writer, reader
>> is the order of evaluation defined? is it preserved?
> This is a bit of a tricky question to answer.
> ...
> So in your example the first writer (W1) will be blocked by the first 
> two Readers (R1,R2)
> but will disable the read fast path and hold the internal mutex.
> W1 will block R3,R4,W2,R5 as they all need to acquire the internal mutex.
> If R1,R2 release the lock, W1 will become unblocked and eventually 
> unlock the lock
> such releasing the mutex. At this time R3,R4,W2,R5 compete for the 
> mutex and whoever
> wins is next in the locking order.

Is there is a chance that so long as there is more than one Reader
waiting for a mutex, a Write lock request may never be granted?

Given the name "read mostly", is there any favouritism towards
Readers vs Writers when competing for the mutex?

Or conversely, if there is always a pending Write request that a
read is never granted?

When R3,R4,W3,R5 compete for the mutex, if R3-5 wins, is
the read fast path enabled again?

If any of the Readers wins, does this mean that all Readers are
dequeued, or only those upto the pending Write?


More information about the freebsd-current mailing list