diff options
author | dlg <> | 2025-07-12 23:59:44 +0000 |
---|---|---|
committer | dlg <> | 2025-07-12 23:59:44 +0000 |
commit | 417b1213b262bbe6d34c708537dff4b062920bfa (patch) | |
tree | 32c204acfdb9e0e6ebf5b8e75fbee0e3d49e2228 /src/lib/libc/stdlib | |
parent | 69147ea8445a511462c02e8ac88d4f75fec3fa1b (diff) | |
download | openbsd-417b1213b262bbe6d34c708537dff4b062920bfa.tar.gz openbsd-417b1213b262bbe6d34c708537dff4b062920bfa.tar.bz2 openbsd-417b1213b262bbe6d34c708537dff4b062920bfa.zip |
add libc specific __cmtx and __rcmtx locks for internal use.
__cmtx provides mutual exclusion using futex(2) and cas on archs
that support it, or _spinlocks on the rest. __rcmtx is a recursive
mutex built on top of __cmtx, so it inherits the use of futex and
cas/spinlock from __cmtx.
until now the options we had for locking between threads in libc
were spinlocks or pthread mutexes. spinlocks use sched_yield to
relax if they have to spin on a contended lock, which we are trying
to minimise the use of as much as possible. pthread_mutex is
relatively large in memory and offers a lot of complicated features
which are unecessary for most of libc. the non cas/futex version
of pthread_mutexes currently relies on __thrsleep and __thrwakeup,
which we also want to deprecate.
having a small futex based lock available everywhere will help us
move away from overuse of spinlocks, and deprecate __thrsleep and
__thrwakeup.
ok kettenis@
jca@ provided his eyes too.
Diffstat (limited to 'src/lib/libc/stdlib')
0 files changed, 0 insertions, 0 deletions