summaryrefslogtreecommitdiff
path: root/lib/libpthread/pthread_types.h
diff options
context:
space:
mode:
authorad <ad@NetBSD.org>2007-08-04 13:37:48 +0000
committerad <ad@NetBSD.org>2007-08-04 13:37:48 +0000
commit50fa8db4e44b07accbfd5f2821987476be3bf05c (patch)
tree04cfc58059fb658923f9a7b24583dd0b3e4437d1 /lib/libpthread/pthread_types.h
parentb108f67c054e0f87f9b653c4d194652a4bfc40cc (diff)
Some significant performance improvements, and a fix for a race with pthread
detach/join. - Make mutex acquire spin for a short time, as done with spinlocks. - Make the number of spins controllable with the env var PTHREAD_NSPINS. - Reduce the amount of time that libpthread internal spinlocks are held. - Rely more on the barrier effects of park/unpark to avoid taking spinlocks. - Simplify the locking around pthreads and the global queues. - Align per-thread sync data on a 128 byte boundary. - Offset thread stacks by a small amount to try and reduce cache thrash.
Diffstat (limited to 'lib/libpthread/pthread_types.h')
-rw-r--r--lib/libpthread/pthread_types.h15
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/libpthread/pthread_types.h b/lib/libpthread/pthread_types.h
index c8fe3d2103e..fd9da70ea87 100644
--- a/lib/libpthread/pthread_types.h
+++ b/lib/libpthread/pthread_types.h
@@ -1,4 +1,4 @@
-/* $NetBSD: pthread_types.h,v 1.6 2007/05/02 21:54:16 ad Exp $ */
+/* $NetBSD: pthread_types.h,v 1.7 2007/08/04 13:37:50 ad Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -54,7 +54,8 @@ struct name { \
struct type **ptqh_last;/* addr of last next element */ \
}
-_PTQ_HEAD(pthread_queue_t, __pthread_st);
+_PTQ_HEAD(pthread_queue_struct_t, __pthread_st);
+typedef struct pthread_queue_struct_t pthread_queue_t;
struct __pthread_st;
struct __pthread_attr_st;
@@ -98,7 +99,7 @@ struct __pthread_mutex_st {
pthread_spin_t ptm_lock;
pthread_spin_t ptm_interlock;
pthread_t ptm_owner;
- struct pthread_queue_t ptm_blocked;
+ pthread_queue_t ptm_blocked;
void *ptm_private;
};
@@ -128,7 +129,7 @@ struct __pthread_cond_st {
/* Protects the queue of waiters */
pthread_spin_t ptc_lock;
- struct pthread_queue_t ptc_waiters;
+ pthread_queue_t ptc_waiters;
pthread_mutex_t *ptc_mutex; /* Current mutex */
void *ptc_private;
@@ -181,8 +182,8 @@ struct __pthread_rwlock_st {
/* Protects data below */
pthread_spin_t ptr_interlock;
- struct pthread_queue_t ptr_rblocked;
- struct pthread_queue_t ptr_wblocked;
+ pthread_queue_t ptr_rblocked;
+ pthread_queue_t ptr_wblocked;
unsigned int ptr_nreaders;
pthread_t ptr_writer;
void *ptr_private;
@@ -214,7 +215,7 @@ struct __pthread_barrier_st {
/* Protects data below */
pthread_spin_t ptb_lock;
- struct pthread_queue_t ptb_waiters;
+ pthread_queue_t ptb_waiters;
unsigned int ptb_initcount;
unsigned int ptb_curcount;
unsigned int ptb_generation;