
On Oct 24, 2006, at 12:15 PM, Peter Dimov wrote:
There's also an implementation by Ion GaztaƱaga:
http://boost.cvs.sourceforge.net/boost/boost/boost/interprocess/ sync/interprocess_upgradable_mutex.hpp?revision=1.4&view=markup
in which he implements yet another Terekhov algorithm (AFAIK).
Imho Terekhov's algorithm is the way to go regarding reader/writer priority. I've beat on this algorithm fairly heavily in my own implementation of it, and it really performs nicely. Take a look at this test case originally inspired by Peter: http://home.twcny.rr.com/hinnant/cpp_extensions/rw_perf.html You can ignore the move-aspects of it, and even the upgradable aspect of it if you want. But try to get the I/O part of it working on your system (gotoxy). Then crank up the number of readers/writers and play with the protected section cost (vec_len). Then observe the progress of the different kinds of threads. In my experiments no thread is ever shut out, no matter how high the contention gets. This is a very desirable property. -Howard