On Sat, Jul 30, 2011 at 07:23:51PM +0200, Jean-Yves Migeon wrote:
> I remember reading articles mentioning how "wonderful" lockless
> algorithms are, except in situation where the additional bus
> locking/atomic ops involved did not really improve the situation in
> highly concurrent systems (and could even make it worse).

Lock free algorithms don't magically fix many CPUs trying to change a
single resource. They do help to avoid contention due to interrupted
critical sections. Essentially, they do guarantee that progress is made,
independent of how many parties try to use a resource.

A mutex based serialisation can be more efficent, if you plan to do more
than one operation on a given object in a short time and you can rule
out interruptions. In that case, the bus locked cycles can be combined
and amortised over the operations.

Noet that for a uncontested resource, the overhead of a mutex for a
single operation tends to be comparable, if store fences have a similar
price than bus locked operation on an owned cache line.


Reply via email to