freebsd-dev/lib/libthr
Kris Kennaway 2017a7cdfe Add a new "non-portable" mutex type, PTHREAD_MUTEX_ADAPTIVE_NP. This
is also implemented in glibc and is used by a number of existing
applications (mysql, firefox, etc).

This mutex type is a default mutex with the additional property that
it spins briefly when attempting to acquire a contested lock, doing
trylock operations in userland before entering the kernel to block if
eventually unsuccessful.

The expectation is that applications requesting this mutex type know
that the mutex is likely to be only held for very brief periods, so it
is faster to spin in userland and probably succeed in acquiring the
mutex, than to enter the kernel and sleep, only to be woken up almost
immediately.  This can help significantly in certain cases when
pthread mutexes are heavily contended and held for brief durations
(such as mysql).

Spin up to 200 times before entering the kernel, which represents only
a few us on modern CPUs.  No performance degradation was observed with
this value and it is sufficient to avoid a large performance drop in
mysql performance in the heavily contended pthread mutex case.

The libkse implementation is a NOP.

Reviewed by:      jeff
MFC after:        3 days
2007-10-29 21:01:47 +00:00
..
arch - Remove variable _thr_scope_system, all threads are system scope. 2006-12-15 11:52:01 +00:00
support Use thr_new syscall to create a new thread, obscure context operations 2005-04-23 02:48:59 +00:00
sys __error could be called too early before libthr is initialized, test 2006-07-12 03:44:05 +00:00
thread Add a new "non-portable" mutex type, PTHREAD_MUTEX_ADAPTIVE_NP. This 2007-10-29 21:01:47 +00:00
libthr.3 - Stop calling libthr alternative as it's now the default 2007-10-22 10:13:38 +00:00
Makefile Tweak the handling of "WITHOUT_LIBPTHREAD". Also remove the accidental 2007-10-09 23:31:11 +00:00
pthread.map Enable symbol versioning by default. Use WITHOUT_SYMVER to disable it. 2007-05-13 14:12:40 +00:00