Re: [LAD] concurrent access on smp

From: Tvrtko Ursulin <tvrtko@email-addr-hidden>
Date: Wed Oct 31 2012 - 22:04:24 EET

On 22/10/12 01:34, Emanuel Rumpf wrote:
> Hi
>
> With some threads running on different CPU,
> accessing a shared pointer (in RAM) atomically (with gcc atomic methods)
>
> my current understanding is:
> - each cpu has its own cache line
> - which is updated on every atomic read/write operation
>
> 1. is that applicable ?
>
> 2. is there a faster or more convenient method, such as
> storing the pointer in fast register shared among different cpu ?

Depends on how you design your data structures and on the specific platform.

On x86 reads and writes of pointers are atomic so you won't ever end up
with the corrupt pointer, but you may end up with a stale one. This may
be, or may not be a problem, depending on your use and design, and there
are ways of designing things around it. If applicable to your use case.

If your data structures and their use require locking, which you would
like to avoid, there is a concept called Read-Copy-Update which is for
example heavily used in the kernel and is also available as an userspace
library (http://lttng.org/urcu).

Tvrtko

_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/listinfo/linux-audio-dev
Received on Thu Nov 1 00:15:01 2012

This archive was generated by hypermail 2.1.8 : Thu Nov 01 2012 - 00:15:01 EET