
On Sep 9, 2005, at 7:57 AM, John Maddock wrote:
If priority policy is the overriding issue, I recommend considering Alexander Terekhov's algorithm summarized here:
Interesting, clearly using interlocked operations where possible is a real win, and would certainly be easy to implement on Win32.
That should be in capitals: Real Win (tm) ;-) http://home.twcny.rr.com/hinnant/cpp_extensions/rw_perf.html (which is a PPC implementation making use of atomic primitives) Note this is not lock-free. It is only lock-free in the case of no contention for the mutex. If there is contention, an OS mutex must be locked. I'm calling it lock-reduced for lack of better terminology at the moment.
Unfortunately, I don't believe the algorithm you provide is compatible with the current interface, which promises to let the user choose how to schedule interleaves between readers and writers. On the other hand, it is that interface which is part of the problem: it introduces too much complexity, and too many code-paths through which locking could occur to be able to analyse the code easily. So maybe we should dump the current interface.
Or maybe independently develop the Terekhov algorithm, and stress test the two side by side ... um if we can get the current interface working. -Howard