On Fri, 2008-10-17 at 08:56 -0400, Paul Coccoli wrote:
> Why do you suspect you need memory barriers? My concern with
this is the core of the "idea" of the thread-safe ringbuffer.
step back. answer the question. what *does* happen?
it means that the read_ptr has an unnecessarily high value, which means
that we *under*-estimate the space available for writing.. ditto for the
write_ptr case, where we *under*-estimate the data available for
we can and *do* anticipate that context switches will occur there -
there is no general way to that execute that operation
(increment-and-mask) in a lock-free atomic way. the idea is that even if
it does happen, the resulting error prevents the buffer from being
misused. of course, its a little inefficient. but until we get cpu's
with atomic inc-and-mask instructions, its the price we pay for going
lock-free (and its a relatively small cost).
Linux-audio-user mailing list