[concurrency-interest] Lock-free mania

Szabolcs Ferenczi szabolcs.ferenczi at gmail.com
Sun Apr 15 20:02:41 EDT 2007

On 16/04/07, David Holmes <dcholmes at optusnet.com.au> wrote:
> Szabolcs Ferenczi wrote:
> > What is the advantage of the lock-free algorithm? Pros:
> >
> > 1: If there is no conflict in the actual interaction among threads,
> >   the overhead is less than by a conventional mutual exclusion
> >   algorithm.
> Lock-free algorithms address the situation where there *is*
> conflict/contention, and where lock-based techniques would require threads
> to be blocked.

I am afraid both flavour addresses the situation when there is
conflict/contention. The main difference is in the abstraction level.

The "lock-based" solution stays at a high abstraction level and does
not specify how to solve the locking. It only defines that
conflict/contention must be avoided. Locking can be implemented by
descheduling threads but it can be implemented by spin locking as
well. It depends on the implementation.

On the other hand, the "lock-free" solution defines how to schedule
the threads (manually). And it is both complicated and difficult to
prove or test.

Do not forget that we are speaking of short term scheduling. Note that
for long term scheduling "lock-free" versions are inefficient.

Best Regards,

More information about the Concurrency-interest mailing list