summaryrefslogtreecommitdiff
path: root/lib/libc/include
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2019-02-13 13:22:15 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2019-02-13 13:22:15 +0000
commitf71b40551bac2215edc94dc33c5d5731e9e26f19 (patch)
treeadc00883bda2ce6a7afdc96b30eb576a5a6c42d0 /lib/libc/include
parent48c89f1b00bc535a347a506d79f0b9a873851a09 (diff)
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.h13
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 {