On 31 Mar 2004 11:39:36 -0600, Jack O'Quin
<joq(a)io.com> wrote:
> It doesn't look all that expensive. The magic is done by a platform-
> dependent compare-and-swap operation. On some SMP machines that can
> be slow, but generally only in high-contention situations (AFAIK).
Arve Knudsen <aknuds-1(a)broadpark.no> writes:
According to the comments it could involve a memory
lock though,
wouldnt this be expensive either way?
Dunno. Depends on the machine implementation.
On the SMP machines I worked with a while back, the cost of a compare
and swap was about 15 or 20 cycles (IIRC) when the cache line was
available in the current CPU, but maybe ten times that if there was a
dirty copy in some other CPU. These things tend to scale with memory
and cache latencies more than with CPU speed, so the effect has likely
become even more pronounced.
For realtime, we need to look at the worst-case, so I guess that can
be pretty bad. Still, even the worst case might be acceptable if it
only happens twice per buffer.
Maybe we could introduce a compile time conditional,
and/or an
environment variable (default would be on)? Perhaps the canary could
be conditional as well.
I don't see a compile-time option being much use. PortAudio is a
shared library, its users will generally all run the same binary.
An environment variable is clumsy, but would work. Is there any
mechanism in PA for setting host-dependent options?
--
joq