diff options
| author | dlg <> | 2025-08-04 01:44:33 +0000 |
|---|---|---|
| committer | dlg <> | 2025-08-04 01:44:33 +0000 |
| commit | 97f291299e43eb39dd2ecdc18098d938d467dac6 (patch) | |
| tree | 062fcd4cb2756c0bc552d938b5727afb2e443123 /src/lib/libc | |
| parent | 7037d4c7b0d5603ef79bf7e7f1b33c2cbbce89f2 (diff) | |
| download | openbsd-97f291299e43eb39dd2ecdc18098d938d467dac6.tar.gz openbsd-97f291299e43eb39dd2ecdc18098d938d467dac6.tar.bz2 openbsd-97f291299e43eb39dd2ecdc18098d938d467dac6.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@
Diffstat (limited to 'src/lib/libc')
| -rw-r--r-- | src/lib/libc/include/thread_private.h | 8 |
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 | |||
| 386 | struct pthread_mutex_attr { | 392 | struct pthread_mutex_attr { |
| 387 | int ma_type; | 393 | int ma_type; |
| 388 | int ma_protocol; | 394 | int ma_protocol; |
