diff options
| author | ad <ad@NetBSD.org> | 2007-08-16 12:01:49 +0000 |
|---|---|---|
| committer | ad <ad@NetBSD.org> | 2007-08-16 12:01:49 +0000 |
| commit | b8833ff53f83de80158512cce3d1ffdde95c3c47 (patch) | |
| tree | c69b4b3372a1ac29f3091040a4846ff1b82f038b /lib/libpthread/pthread_lock.c | |
| parent | 9247850afb4080eb4333371fa894b8300c5a375c (diff) | |
- Reinitialize the absolute minimum when recycling user thread state.
Chops another ~10% off create/join in a loop on i386.
- Disable low level debugging as this is stable. Improves benchmarks
across the board by a small percentage. Uncontested mutex acquire
and release in a loop becomes about 8% quicker.
- Minor cleanup.
Diffstat (limited to 'lib/libpthread/pthread_lock.c')
| -rw-r--r-- | lib/libpthread/pthread_lock.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/lib/libpthread/pthread_lock.c b/lib/libpthread/pthread_lock.c index c5d4b91a8aa..f39c68f4a0c 100644 --- a/lib/libpthread/pthread_lock.c +++ b/lib/libpthread/pthread_lock.c @@ -1,4 +1,4 @@ -/* $NetBSD: pthread_lock.c,v 1.21 2007/08/04 13:37:49 ad Exp $ */ +/* $NetBSD: pthread_lock.c,v 1.22 2007/08/16 12:01:49 ad Exp $ */ /*- * Copyright (c) 2001, 2006, 2007 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: pthread_lock.c,v 1.21 2007/08/04 13:37:49 ad Exp $"); +__RCSID("$NetBSD: pthread_lock.c,v 1.22 2007/08/16 12:01:49 ad Exp $"); #include <sys/types.h> #include <sys/lock.h> @@ -46,10 +46,14 @@ __RCSID("$NetBSD: pthread_lock.c,v 1.21 2007/08/04 13:37:49 ad Exp $"); #include <errno.h> #include <unistd.h> #include <stdio.h> +#include <stdlib.h> #include "pthread.h" #include "pthread_int.h" +/* How many times to try acquiring spin locks on MP systems. */ +#define PTHREAD__NSPINS 1024 + #ifdef PTHREAD_SPIN_DEBUG_PRINT #define SDPRINTF(x) DPRINTF(x) #else @@ -106,10 +110,18 @@ pthread__simple_unlock(__cpu_simple_lock_t *alp) * we fall back onto machine-dependent atomic lock primitives. */ void -pthread__lockprim_init(int ncpu) +pthread__lockprim_init(void) { + char *p; + + if ((p = getenv("PTHREAD_NSPINS")) != NULL) + pthread__nspins = atoi(p); + else if (pthread__concurrency != 1) + pthread__nspins = PTHREAD__NSPINS; + else + pthread__nspins = 1; - if (ncpu != 1) { + if (pthread__concurrency != 1) { pthread__atomic = 1; return; } |
