Re: rmlock question..
- From: Stephan Uphoff <ups@xxxxxxxxxxx>
- Date: Tue, 27 Nov 2007 21:51:04 -0500
Darren Reed wrote:
Stephan Uphoff wrote:Sorry for the delay in answering.Julian Elischer wrote:Julian Elischer wrote:This is a bit of a tricky question to answer.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 getin fact if the requests are of the order
my turn, or do I have to wait for a moment where there are no more readers before I get a go?
reader, reader, writer, reader, reader, writer, reader
is the order of evaluation defined? is it preserved?
...
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.
Somehow your post did not make it to my inbox.
Is there is a chance that so long as there is more than one ReaderNo. Even if all reader waiting for the mutex have a higher priority and need
waiting for a mutex, a Write lock request may never be granted?
to acquire the mutex for a short time no new readers will need the mutex as long
as the readlock fastpath is enabled. The reader fastpath is only disabled
once the writer holds the mutex.
Given the name "read mostly", is there any favouritism towardsNo the name is derived from the fact that the lock is designed to work mostly
Readers vs Writers when competing for the mutex?
in a state where the reader fastpath can be used.
Using the fastpath the shared lock can be acquired without any atomic operations or
dirtying of shared cache lines.
Or conversely, if there is always a pending Write request that aYes - if there is always a write request and the write threads always
read is never granted?
have better priority than the read request.
But then you really, really have picked the wrong lock.
( And you would have the same problem just using a mutex)
When R3,R4,W3,R5 compete for the mutex, if R3-5 wins, isI assume you mean R3, R4, W2, R5
the read fast path enabled again?
Yes - however none of R3-5 will be retried using the fastpath.
( All need to acquire the mutex)
If any of the Readers wins, does this mean that all Readers areNo - if a reader wins it enables the fastpath - but currently blocked readers
dequeued, or only those upto the pending Write?
are not on the fastpath and still need to acquire the internal mutex.
In this case R3, R4, will acquire the mutex for a short time.
Then W2 will acquire the internal mutex and wait for R3,R4 to release the read lock.
Once W2 release the write lock (and as such the internal mutex) R5 will be
unblocked and can acquire the internal mutex.
Actually it is not quite as deterministic as lock order on mutexes is not
that strictly enforced.
This may change in the future if I replace the internal rmlock
mutex with lower level primitives.
Right now rmlock is in a state where only the read fastpath is really optimized.
The rest is functional complete but I expect some tuning to happen once we
have more experience with situations where rmlocks are useful.
Stephan
_______________________________________________
freebsd-current@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscribe@xxxxxxxxxxx"
- References:
- rmlock question..
- From: Julian Elischer
- Re: rmlock question..
- From: Julian Elischer
- Re: rmlock question..
- From: Stephan Uphoff
- Re: rmlock question..
- From: Darren Reed
- rmlock question..
- Prev by Date: Re: 802.11 w/ WEP requires deftxkey explicitly set after 2007-08-24
- Next by Date: Re: bypassing certain cvs commits
- Previous by thread: Re: rmlock question..
- Next by thread: Re: rmlock question..
- Index(es):
Relevant Pages
|