On Fri, May 2, 2014 at 6:37 AM, Antony Polukhin
Hi,
This is just a refining of idea that was once implemented and worked well. The idea was to make shared spin lock. Here is some pseudo-code:
When all the *_wait() and writer_*() functions do nothing we get a shared spinlock.
[snip]
Now if we add helper mutex and make all the *_wait() functions to lock and unlock mutex; writer_start() - lock the mutex; writer finished() - unlock the mutex... we get a simplified shared_mutex that is faster (in theory) than current implementation.
Is there an interest in such shared_spinlock_t? Any comments, suggestions?
Not sure, you generally want to use a spinlock when you expect contention to be very low. If you expect contention to be high enough that a r/w lock could be a win, you probably do not want to spin anyway. There is also the geneal issue of naive r/w locks with readers contending for an exclusive cacheline. -- gpd