On Thu, Dec 26, 2013 at 4:19 PM, comex <com...@gmail.com> wrote:
> On Thu, Dec 26, 2013 at 8:48 PM, Daniel Micay <danielmi...@gmail.com> wrote:
>> Acquiring and releasing a mutex when there's low contention takes two
>> atomic operations. Switching to a linked data structure adds far more
>> overhead than an extra atomic operation.
>> [...]
>> A simple array-backed circular buffer has a tiny lock scope, so it
>> won't ever have high contention. In a less simple case, a mutex will
>> spin for a bit before falling back to a `futex` system call.
>
> Fair enough, but why do you assume a lock-free queue is a linked data
> structure?  A simple (bounded) array-backed circular buffer can be
> lock-free too and then there are zero atomic operations.

Lock-free data structures use atomic operations... you're doing at
least one atomic operation or you won't have consistency between
threads. An atomic operation will result in cache synchronization and
stall the CPU pipeline. On an architecture with a weaker memory model
(not x86), it might not have to stall the pipeline as much if you use
a weaker ordering.
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to