|
Boost Users : |
Subject: Re: [Boost-users] [Thread] order of shared_lock and unique_lock acquisitions
From: Roland Bock (rbock_at_[hidden])
Date: 2009-01-09 09:06:02
Steven,
thanks for the answer!
> First off, there is a race calculating the sleep times. There is
> absolutely
> no guarantee that the readers and writers get any particular distribution
> of wait times. For instance all the readers could get the early read
> times.
> Not to mention that it is possible for all the threads to wait for 5
> seconds.
According to the log, none of this does happen, but you are right, this
could happen (and it does sometimes).
> In addition, while the reader or the writer does the second sleep,
> (while still holding the lock)
> all the other threads come out of their initial sleeps.
OK, and then Zeljko's answer comes into play which says that Mutexes are
not FIFO.
Still, I wonder why I got two readers in parallel, and the next readers
do not acquire the shared lock before the first two release the shared
lock (and no writer in between)?
Also, are any preferred orders, like writers having precedence over
readers (in order to avoid writer starvation)?
Thanks and regards,
Roland
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net