Attached is a patch to implement futex_wait/wake with pthread.
I tested this on FreeBSD/x86 6.1-RELEASE, 7.0-CURRENT and Linux/x86-64
2.6.16 (openSUSE 10.1).
I implemented this because the current implementation of lutex has
1. It uses pthread's mutex / condition as Lisp level one.
Most functions of pthread are not safe to unwind frames. When
frames are unwinded from signal handler across blocking
pthread_mutex_lock() or pthread_cond_wait(), the behaviour is
Mostly, this does not causes any problems. But if you are unlucky,
deadlocks will be occur.
This was the reason of very occasional hang ups.
2. GC or core processing is not stable.
As Anthony Juckel mentioned, there are some problems saving or
loading core files. Random failures occur core.test.sh,
foreign.test.sh, or init.test.sh even on Linux/x86-64.
I know emulating low-level interfaces like futex with high-level
interfaces like pthread is not efficient, and providing high-level
interfaces as lutex is preferable for long-term resolution. So I will
continue to work on lutex to fix above problems.