From 976e689fa21b88566fb9707a45c85dc8e85b2886 Mon Sep 17 00:00:00 2001 From: mpi <> Date: Wed, 13 Feb 2019 13:22:14 +0000 Subject: 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@ --- src/lib/libc/include/thread_private.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/lib/libc/include/thread_private.h b/src/lib/libc/include/thread_private.h index 774e0cba1f..98dfaa6322 100644 --- a/src/lib/libc/include/thread_private.h +++ b/src/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 */ @@ -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 { -- cgit v1.2.3-55-g6feb