
Zitat von Tim Blechmann
as rule of thumb, i am using spinlocks in the following cases: - locks are acquired very rarely - critical region is very short (a instructions) - the number of threads to be synchronized is lower than the number of cpu cores - the synchronized threads have a similar (possibly real-time) priority
a set of condition also known as "never" ;-) if the lock is acquired "very rarely" what is the advantage of a spinlock anyway?
btw, using yield() inside a spinlock may cause unwanted behavior, since it preempts the calling thread, but the scheduler keeps it as `ready' instead of `blocked'. so it may wake up, before it can acquire the mutex, burning cpu cycles.
yes, I guess that´s what I was observing, switching between the yield()ing threads instead of continueing with the thread that acquired the lock.