diff options
| author | mpi <> | 2019-02-13 13:22:14 +0000 |
|---|---|---|
| committer | mpi <> | 2019-02-13 13:22:14 +0000 |
| commit | 976e689fa21b88566fb9707a45c85dc8e85b2886 (patch) | |
| tree | f36031e2963f066019269aaf12a618618e4b699d /src | |
| parent | 2652ec9980da8f6756781c58d96e55ca24dd7dcb (diff) | |
| download | openbsd-976e689fa21b88566fb9707a45c85dc8e85b2886.tar.gz openbsd-976e689fa21b88566fb9707a45c85dc8e85b2886.tar.bz2 openbsd-976e689fa21b88566fb9707a45c85dc8e85b2886.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 'src')
| -rw-r--r-- | src/lib/libc/include/thread_private.h | 13 |
1 files changed, 12 insertions, 1 deletions
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 @@ | |||
| 1 | /* $OpenBSD: thread_private.h,v 1.34 2019/01/10 18:45:33 otto Exp $ */ | 1 | /* $OpenBSD: thread_private.h,v 1.35 2019/02/13 13:22:14 mpi 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 | ||
| @@ -298,6 +298,10 @@ struct pthread_cond { | |||
| 298 | struct pthread_mutex *mutex; | 298 | struct pthread_mutex *mutex; |
| 299 | }; | 299 | }; |
| 300 | 300 | ||
| 301 | struct pthread_rwlock { | ||
| 302 | volatile unsigned int value; | ||
| 303 | }; | ||
| 304 | |||
| 301 | #else | 305 | #else |
| 302 | 306 | ||
| 303 | struct pthread_mutex { | 307 | struct pthread_mutex { |
| @@ -315,6 +319,13 @@ struct pthread_cond { | |||
| 315 | struct pthread_mutex *mutex; | 319 | struct pthread_mutex *mutex; |
| 316 | clockid_t clock; | 320 | clockid_t clock; |
| 317 | }; | 321 | }; |
| 322 | |||
| 323 | struct pthread_rwlock { | ||
| 324 | _atomic_lock_t lock; | ||
| 325 | pthread_t owner; | ||
| 326 | struct pthread_queue writers; | ||
| 327 | int readers; | ||
| 328 | }; | ||
| 318 | #endif /* FUTEX */ | 329 | #endif /* FUTEX */ |
| 319 | 330 | ||
| 320 | struct pthread_mutex_attr { | 331 | struct pthread_mutex_attr { |
