Subject: lock-free data structures
To: None <tech-kern@netbsd.org>
From: None <zvrba@globalnet.hr>
List: tech-kern
Date: 01/02/2006 19:56:14
-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160

Sorry if I'm a bit off-topic, but this is the only kernel-developers
mailing list that I'm subscribed to. The question is a practical one and
I believe that kernel developers can give the most informed answer.

Recently I've come across many papers describing the construction of
lock-free data structures using compare&exchange instructions. Such
implementations do not require explicit locks (mutexes) in an MP
environment. The advantages are more (no explicit locking needed) or
less (performance gains) obvious, so the question arises: why aren't
such data structures used more widely (in general and in the kernel
code?)

I know that Linux has adopted RCU, but again the example code for the
linked list traversal calls rcu_read_lock() / rcu_read_unlock() (thus,
not fulfilling the promise of lock-free code). Why didn't BSDs adopt RCU?
[ Please, I'm not trying to start a Linux vs. BSD war! This is a simple and
honest question related to my general inquiry. ]

Bottom line: what's the "catch" with lock-free data structures?

An immediate drawback is that not all architectures support the cmpxchg
instruction. What are others? Is the possible performance gain negligible
compared to the required effort of recoding a large volume of code?

Thanks for your answers.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFDuXdOFtofFpCIfhMRAyRpAJ9dmtcZG+fK+Zco5fghyhkU+QiaQgCfZdkQ
GZ9RTuOv2Y5ZOn+ofS3bJ3U=
=HGYy
-----END PGP SIGNATURE-----