Boost logo

Boost Users :

Subject: Re: [Boost-users] [Thread] Writer/Reader strange scheduling
From: Roland Bock (rbock_at_[hidden])
Date: 2010-08-10 11:05:07


On 08/10/2010 04:28 PM, Stefan Strasser wrote:
>> isn't that a waste? Why make reader 3 and 4 waiting and then make
>> those running
>> before the writer? The code to reproduce that is at the end.
>
> I don't think Boost.Thread specifies this behaviour, so it is probably
> platform-dependent.
> I'm guessing readers 3 and 4 have to wait because the writer thread
> requested an exclusive lock (and otherwise the writer thread would be
> starved), but once all locks have been released it is a decision of the
> OS scheduler which thread is then woken up first and can acquire a lock
> - one of the reader threads in this case apparently.

Right, if you want an "order preserving shared mutex", you have to write
it yourself.


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