"Antoninus Twink" <no****@nospam.invalidwrote in message
news:sl*******************@nospam.invalid...
On 9 Apr 2008 at 13:12, Thad Smith wrote:
>InuY4sha wrote:
>>Can anybody give me the basics (or a *basic* instructions link)
regarding spinlocks and their usage? I really can't understand their
meaning...
http://en.wikipedia.org/wiki/Spin_lock
That article seems to focus more on implementing spinlocks than on
using them...
A spinlock has the same function as a mutex: they're both mutual
exclusion locks. The only difference is the behavior when a thread tries
to gain a lock, but the lock is already held by another thread. If a
mutex is held by another thread, the current thread is suspended and
doesn't resume until it can gain the lock.
[...]
There are so-called adaptive mutexs that act like spinlocks when contention
arises. The difference is that the spin-count is bounded. When the limit is
reached, the calling threads becomes a member of the mutexs waitset.