|
Boost : |
From: Andreas Pokorny (andreas.pokorny_at_[hidden])
Date: 2007-09-16 05:11:24
Hello,
2007/9/16, Sid Sacek <ssacek_at_[hidden]>:
> I don't see much benefit of the spin-lock approach over a system mutex,
> since the system mutex at least allows other threads to continue running
> while the mutex is being held.
In our company use spin locks instead of system mutex, because we
usually have close to one thousand objects that are used by different
threads. Creating such a large number is often not supported.
> A hybrid of a spin-lock and mutex sounds better to me than a simple
> spin-lock. What I mean is that if the spin-lock does not terminate its loop
> in short order, that means the lock loop is going last for a very long time
> ( possibly up to 10-milliseconds. ) If the loop does not exit quickly, then
> yield the processor to some other thread, (possibly even the thread that's
> holding the lock in the first place.)
Yes, we used that approach and on systems like MIPS with LL/SC we
also loop a few times before giving up. According to the documentation
many false-failures of the conditional seem to be possible. Hence trying
a few times seemed reasonable. Giving up is usually done by sleeping.
Doesnt ARM support ll/sc like operations?
Regards
Andreas Pokorny
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk