|
Boost Users : |
Subject: Re: [Boost-users] Q: N00b spinlock
From: Tim Blechmann (tim_at_[hidden])
Date: 2010-01-21 15:45:46
On 01/21/2010 09:10 PM, strasser_at_[hidden] wrote:
> Zitat von Tim Blechmann <tim_at_[hidden]>:
>
>> 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" ;-)
almost never ;)
> if the lock is acquired "very rarely" what is the advantage of a
> spinlock anyway?
sry, i wanted to write:
`in very rare cases different threads try to acquire a lock'
spinlocks are low-level primitives and they shouldn't be used, unless
you want to avoid that the os preempts the locking thread.
cheers, tim
-- tim_at_[hidden] http://tim.klingt.org There's no such entity as "most people". These are generalities. All generalities are meaningless. You've got to pin it down to a specific person doing a specific thing at a specific time and space. William S. Burroughs
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net