diff options
author | 2019-02-13 13:22:14 +0000 | |
---|---|---|
committer | 2019-02-13 13:22:14 +0000 | |
commit | 5ecdd0566b441ae0b99e73f410875e05dc0fa5b7 (patch) | |
tree | a6db293fa6f9140c6a27a9813459069aa9e6007d /lib/libc/include | |
parent | Import the existing rwlock implementation for architectures that cannot (diff) | |
download | wireguard-openbsd-5ecdd0566b441ae0b99e73f410875e05dc0fa5b7.tar.xz wireguard-openbsd-5ecdd0566b441ae0b99e73f410875e05dc0fa5b7.zip |
New futex(2) based rwlock implementation based on the mutex code.
This implementation reduces contention because threads no longer need
to spin calling sched_yield(2) before going to sleep.
Tested by many, thanks!
ok visa@, pirofti@
Diffstat (limited to 'lib/libc/include')
-rw-r--r-- | lib/libc/include/thread_private.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/libc/include/thread_private.h b/lib/libc/include/thread_private.h index 774e0cba1fb..98dfaa63223 100644 --- a/lib/libc/include/thread_private.h +++ b/lib/libc/include/thread_private.h @@ -1,4 +1,4 @@ -/* $OpenBSD: thread_private.h,v 1.34 2019/01/10 18:45:33 otto Exp $ */ +/* $OpenBSD: thread_private.h,v 1.35 2019/02/13 13:22:14 mpi Exp $ */ /* PUBLIC DOMAIN: No Rights Reserved. Marco S Hyman <marc@snafu.org> */ @@ -298,6 +298,10 @@ struct pthread_cond { struct pthread_mutex *mutex; }; +struct pthread_rwlock { + volatile unsigned int value; +}; + #else struct pthread_mutex { @@ -315,6 +319,13 @@ struct pthread_cond { struct pthread_mutex *mutex; clockid_t clock; }; + +struct pthread_rwlock { + _atomic_lock_t lock; + pthread_t owner; + struct pthread_queue writers; + int readers; +}; #endif /* FUTEX */ struct pthread_mutex_attr { |