summaryrefslogtreecommitdiff
path: root/db2/mutex
diff options
context:
space:
mode:
Diffstat (limited to 'db2/mutex')
-rw-r--r--db2/mutex/README8
-rw-r--r--db2/mutex/mutex.c16
2 files changed, 8 insertions, 16 deletions
diff --git a/db2/mutex/README b/db2/mutex/README
index 30d6b6a7d1..fceeef7ed8 100644
--- a/db2/mutex/README
+++ b/db2/mutex/README
@@ -1,4 +1,4 @@
-# @(#)README 10.1 (Sleepycat) 4/12/97
+# @(#)README 10.2 (Sleepycat) 11/25/97
Resource locking routines: lock based on a db_mutex_t. All this gunk
(including trying to make assembly code portable), is necessary because
@@ -11,9 +11,9 @@ information.
If HAVE_SPINLOCKS is defined (i.e. we know how to do test-and-sets for
this compiler/architecture combination), we try and lock the resource tsl
-TSL_DEFAULT_SPINS times. If we can't acquire the lock that way, we use
-a system call to sleep for 10ms, 20ms, 40ms, etc. (The time is bounded
-at 1 second, just in case.) Using the timer backoff means that there are
+__db_tsl_spins times. If we can't acquire the lock that way, we use a
+system call to sleep for 10ms, 20ms, 40ms, etc. (The time is bounded at
+1 second, just in case.) Using the timer backoff means that there are
two assumptions: that locks are held for brief periods (never over system
calls or I/O) and that locks are not hotly contested.
diff --git a/db2/mutex/mutex.c b/db2/mutex/mutex.c
index 7c8ea6ebd1..6e87c5f215 100644
--- a/db2/mutex/mutex.c
+++ b/db2/mutex/mutex.c
@@ -8,7 +8,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)mutex.c 10.28 (Sleepycat) 10/31/97";
+static const char sccsid[] = "@(#)mutex.c 10.29 (Sleepycat) 11/25/97";
#endif /* not lint */
#ifndef NO_SYSTEM_INCLUDES
@@ -101,12 +101,6 @@ static const char sccsid[] = "@(#)mutex.c 10.28 (Sleepycat) 10/31/97";
#endif /* HAVE_SPINLOCKS */
-#ifdef MORE_THAN_ONE_PROCESSOR
-#define TSL_DEFAULT_SPINS 5 /* Default spins before block. */
-#else
-#define TSL_DEFAULT_SPINS 1 /* Default spins before block. */
-#endif
-
/*
* __db_mutex_init --
* Initialize a DB mutex structure.
@@ -130,6 +124,7 @@ __db_mutex_init(mp, off)
#ifdef HAVE_SPINLOCKS
TSL_INIT(&mp->tsl_resource);
+ mp->spins = __os_spin();
#else
mp->off = off;
#endif
@@ -155,11 +150,8 @@ __db_mutex_lock(mp, fd)
int nspins;
for (usecs = MS(10);;) {
- /*
- * Try and acquire the uncontested resource lock for
- * TSL_DEFAULT_SPINS.
- */
- for (nspins = TSL_DEFAULT_SPINS; nspins > 0; --nspins)
+ /* Try and acquire the uncontested resource lock for N spins. */
+ for (nspins = mp->spins; nspins > 0; --nspins)
if (TSL_SET(&mp->tsl_resource)) {
#ifdef DEBUG
if (mp->pid != 0) {