Hello,
That's not the end of the story, i have benchmarked
the following Spin lock with exponential backoff that i am
using:
http://code.google.com/p/gpdelphiunits/source/browse/trunk/src/SpinLock.pas?r=37
And this is not good at all, cause there is a problem with
the exponential backoff , i have benchmarked it and i have notived
that the backoff slows down a lot the critical section even if the
contention is not high, so this TTAS with an exponential backoff is a
stupid thing , the ticket spinlock is also a stupid thing.
I have also benchmarked the ticket spinlock and found that it has a poor
performance cause in the case of a spinlock without tickets when it is
unlocked() the first thread that comes first to the lock() will enter
immediatly the locked section, but that's not the case with a Ticket
spinlock cause if the first thread that enters the lock() first has not
yet the ticket to enter, the other thread that has the ticket to enter
and that is waiting for his turn will wait longer , so this is why the
Ticket spinlock has also a poor performance compared to a simple
spinlock with a backoff.
So i will advise you to avoid the Spinlock with exponential backoff and
the Ticket spinlock.
Thank you,
Amine Moulay Ramdane.