summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordlg <>2025-08-04 01:44:33 +0000
committerdlg <>2025-08-04 01:44:33 +0000
commit451323135e56bc52945da72e2bf9f6b0992e35b3 (patch)
tree062fcd4cb2756c0bc552d938b5727afb2e443123
parentfc8be960288820947950f2a89a6dfaa165995605 (diff)
downloadopenbsd-451323135e56bc52945da72e2bf9f6b0992e35b3.tar.gz
openbsd-451323135e56bc52945da72e2bf9f6b0992e35b3.tar.bz2
openbsd-451323135e56bc52945da72e2bf9f6b0992e35b3.zip
replace the flockfile backend with a per FILE recursive mutex.
the flockfile implementation in thread/rthread_file.c used an external lock, and associated it with the relevant FILE * as needed. this isn't great for a lot of reasons, complexity being the big one, but the straw that broke the camels back is that it uses a single spinlock to coordinate all of this, which in turn generates a lot of sched_yield syscalls. this avoids all the code complexity and the spinlock by just embedding a small __rctmx in every FILE. tested by and ok tb@ jca@ ok claudio@
-rw-r--r--src/lib/libc/include/thread_private.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/lib/libc/include/thread_private.h b/src/lib/libc/include/thread_private.h
index 7e7c716e2a..3e1dbcdf6e 100644
--- a/src/lib/libc/include/thread_private.h
+++ b/src/lib/libc/include/thread_private.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: thread_private.h,v 1.39 2025/07/16 16:22:58 deraadt Exp $ */ 1/* $OpenBSD: thread_private.h,v 1.40 2025/08/04 01:44:33 dlg Exp $ */
2 2
3/* PUBLIC DOMAIN: No Rights Reserved. Marco S Hyman <marc@snafu.org> */ 3/* PUBLIC DOMAIN: No Rights Reserved. Marco S Hyman <marc@snafu.org> */
4 4
@@ -383,6 +383,12 @@ struct __rcmtx {
383 unsigned int depth; 383 unsigned int depth;
384}; 384};
385 385
386#define __RCMTX_INITIALIZER() { \
387 .owner = NULL, \
388 .mtx = __CMTX_INITIALIZER(), \
389 .depth = 0, \
390}
391
386struct pthread_mutex_attr { 392struct pthread_mutex_attr {
387 int ma_type; 393 int ma_type;
388 int ma_protocol; 394 int ma_protocol;