aboutsummaryrefslogtreecommitdiff
path: root/db2/mutex
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-06-13 13:36:34 +0000
committerUlrich Drepper <drepper@redhat.com>1999-06-13 13:36:34 +0000
commitec239360d13518a13f572b635d036c7d10028010 (patch)
treebdb5111363f45d2107849c2456b575d72779174c /db2/mutex
parentfc3703521650a9b6db910a50c4fc0f410496e134 (diff)
downloadglibc-ec239360d13518a13f572b635d036c7d10028010.tar
glibc-ec239360d13518a13f572b635d036c7d10028010.tar.gz
glibc-ec239360d13518a13f572b635d036c7d10028010.tar.bz2
glibc-ec239360d13518a13f572b635d036c7d10028010.zip
Update.
* db2/Makefile (distribute): Remove files which do not exist anymore.
Diffstat (limited to 'db2/mutex')
-rw-r--r--db2/mutex/alpha.dec25
-rw-r--r--db2/mutex/alpha.gcc52
-rw-r--r--db2/mutex/mutex.c49
-rw-r--r--db2/mutex/parisc.hp29
-rw-r--r--db2/mutex/uts4_cc.s (renamed from db2/mutex/uts4.cc.s)0
5 files changed, 30 insertions, 125 deletions
diff --git a/db2/mutex/alpha.dec b/db2/mutex/alpha.dec
deleted file mode 100644
index 83ed371136..0000000000
--- a/db2/mutex/alpha.dec
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * @(#)alpha.dec 8.3 (Sleepycat Software) 1/18/97
- *
- * The DEC C asm acts as a pseudo-call. The first argument is the assembly
- * code, and the remaining arguments are assigned as in a procedure call, to
- * r16, r17, etc. (represented in asm as %a0, %a1, and so forth).
- *
- * From: Dave Butenhof.
- */
-
-#include <c_asm.h>
-
-#define TSL_SET(tsl) (asm ("mb; \
- 10: ldl_l %v0,(%a0) ; \
- bne %v0,30f ; \
- or %v0,1,%r1 ; \
- stl_c %r1,(%a0) ; \
- beq %r1,20f ; \
- mb ; \
- br %r31,30f ; \
- 20: br %r31,10b ; \
- 30: ", (tsl)))
-
-THIS WAS NOT CONVERTED TO TAKE A POINTER AS AN ARGUMENT...
-#define TSL_UNSET(tsl) (asm ("mb"), *(tsl) = 0)
diff --git a/db2/mutex/alpha.gcc b/db2/mutex/alpha.gcc
deleted file mode 100644
index 247d04cf31..0000000000
--- a/db2/mutex/alpha.gcc
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * @(#)alpha.gcc 10.1 (Sleepycat) 4/12/97
- *
- * The code appearing below is taken from Richard L. Sites, ed. "Alpha
- * Architecture Reference Manual", Digital Press, 1992, page 5-7 and 5-8.
- * There are 2 modifications:
- *
- * 1. The jump from blbs __r1,30f to !__r1, which is dictated by the way the
- * TSL_SET macro is used. The code suggested in Sites includes the main loop
- * of the spin lock, whereas in this code the rest the loop is specified in C.
- * The generated code might be suboptimal if the compiler generates a forward
- * branch for the usual case in which the mutex is uncontested.
- *
- * 2. At label 20, Sites suggests including code for testing for an excessive
- * number of _processor_ lock conflicts. (The seq_c instruction stores its
- * first argument provided that no other processor has written to a byte range
- * including its memory-location argument.) Absent such checking the code
- * below could conceivably stall silently on a multiprocessor alpha, depending
- * on how often processor/processor conflicts occur in a particular byte range.
- *
- * Note that the mb ("memory-barrier") instruction in TSL_UNSET is critical to
- * correct operation in a multiprocessor alpha (as is, of course, the mb in
- * the TSL_SET macro). Without the mb, changes to shared memory that occurred
- * inside the critical section (before the TSL_UNSET) might reach shared memory
- * _after_ the change of tsl to 0, thereby permitting another processor to see
- * an inconsistent view of the data protected by the mutex.
- *
- * For gcc/alpha, 0 is clear, 1 is set.
- */
-#define TSL_SET(tsl) ({ \
- register tsl_t *__l = (tsl); \
- register tsl_t __r1, __r2; \
- __asm__ volatile(" \n\
- 10: ldq_l %0,(%2) \n\
- blbs %0,30f \n\
- or %0,1,%1 \n\
- stq_c %1,(%2) \n\
- beq %1,20f \n\
- mb \n\
- br 30f \n\
- 20: br 10b \n\
- 30: " \
- : "=&r" (__r1), "=&r" (__r2) \
- : "r" (__l)); \
- !__r1; \
-})
-
-#define TSL_UNSET(tsl) ({ \
- register tsl_t *__l = (tsl); \
- __asm__ volatile("mb; stq $31,(%0);" : : "r" (__l)); \
-})
-#define TSL_INIT(tsl) TSL_UNSET(tsl)
diff --git a/db2/mutex/mutex.c b/db2/mutex/mutex.c
index de0d0e23fe..acc6aa07c9 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.48 (Sleepycat) 5/23/98";
+static const char sccsid[] = "@(#)mutex.c 10.52 (Sleepycat) 11/8/98";
#endif /* not lint */
#ifndef NO_SYSTEM_INCLUDES
@@ -37,9 +37,12 @@ static const char sccsid[] = "@(#)mutex.c 10.48 (Sleepycat) 5/23/98";
#if defined(HAVE_FUNC_MSEM)
/*
- * XXX
- * Should we not use MSEM_IF_NOWAIT and let the system block for us?
- * I've no idea if this will block all threads in the process or not.
+ * !!!
+ * Do not remove the MSEM_IF_NOWAIT flag. The problem is that if a single
+ * process makes two msem_lock() calls in a row, the second one returns an
+ * error. We depend on the fact that we can lock against ourselves in the
+ * locking subsystem, where we set up a mutex so that we can block ourselves.
+ * Tested on OSF1 v4.0.
*/
#define TSL_INIT(x) (msem_init(x, MSEM_UNLOCKED) == NULL)
#define TSL_INIT_ERROR 1
@@ -74,6 +77,17 @@ static const char sccsid[] = "@(#)mutex.c 10.48 (Sleepycat) 5/23/98";
#define TSL_UNSET(x) _lock_clear(x)
#endif
+#ifdef HAVE_FUNC_VMS
+#include <builtins.h>
+#ifdef __ALPHA
+#define TSL_SET(tsl) (!__TESTBITSSI(tsl, 0))
+#else /* __VAX */
+#define TSL_SET(tsl) (!(int)_BBSSI(0, tsl))
+#endif
+#define TSL_UNSET(tsl) (*(tsl) = 0)
+#define TSL_INIT(tsl) TSL_UNSET(tsl)
+#endif
+
#ifdef HAVE_ASSEM_PARISC_GCC
#include "parisc.gcc"
#endif
@@ -181,7 +195,7 @@ __db_mutex_lock(mp, fd)
#ifdef HAVE_SPINLOCKS
COMPQUIET(fd, 0);
- for (usecs = MS(10);;) {
+ for (usecs = MS(1);;) {
/* Try and acquire the uncontested resource lock for N spins. */
for (nspins = mp->spins; nspins > 0; --nspins)
if (TSL_SET(&mp->tsl_resource)) {
@@ -193,19 +207,17 @@ __db_mutex_lock(mp, fd)
}
mp->pid = getpid();
#endif
- if (usecs == MS(10))
+ if (usecs == MS(1))
++mp->mutex_set_nowait;
else
++mp->mutex_set_wait;
return (0);
}
- /* Yield the processor; wait 10ms initially, up to 1 second. */
- if (__db_yield == NULL || __db_yield() != 0) {
- (void)__db_sleep(0, usecs);
- if ((usecs <<= 1) > SECOND)
- usecs = SECOND;
- }
+ /* Yield the processor; wait 1ms initially, up to 1 second. */
+ __os_yield(usecs);
+ if ((usecs <<= 1) > SECOND)
+ usecs = SECOND;
}
/* NOTREACHED */
@@ -218,15 +230,14 @@ __db_mutex_lock(mp, fd)
for (locked = 0, mypid = getpid();;) {
/*
- * Wait for the lock to become available; wait 10ms initially,
+ * Wait for the lock to become available; wait 1ms initially,
* up to 1 second.
*/
- for (usecs = MS(10); mp->pid != 0;)
- if (__db_yield == NULL || __db_yield() != 0) {
- (void)__db_sleep(0, usecs);
- if ((usecs <<= 1) > SECOND)
- usecs = SECOND;
- }
+ for (usecs = MS(1); mp->pid != 0;) {
+ __os_yield(usecs);
+ if ((usecs <<= 1) > SECOND)
+ usecs = SECOND;
+ }
/* Acquire an exclusive kernel lock. */
k_lock.l_type = F_WRLCK;
diff --git a/db2/mutex/parisc.hp b/db2/mutex/parisc.hp
deleted file mode 100644
index bd0e37fc78..0000000000
--- a/db2/mutex/parisc.hp
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * @(#)parisc.hp 8.6 (Sleepycat) 6/2/98
- *
- * Copyright (c) 1996-1997, The University of Utah and the Computer Systems
- * Laboratory at the University of Utah (CSL). All rights reserved.
- *
- * Permission to use, copy, modify and distribute this software is hereby
- * granted provided that (1) source code retains these copyright, permission,
- * and disclaimer notices, and (2) redistributions including binaries
- * reproduce the notices in supporting documentation, and (3) all advertising
- * materials mentioning features or use of this software display the following
- * acknowledgement: ``This product includes software developed by the Computer
- * Systems Laboratory at the University of Utah.''
- *
- * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS
- * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF
- * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * CSL requests users of this software to return to csl-dist@cs.utah.edu any
- * improvements that they make and grant CSL redistribution rights.
- */
-
-/*
- * The PA-RISC has a "load and clear" instead of a "test and set" instruction.
- * The 32-bit word used by that instruction must be 16-byte aligned hence we
- * allocate 16 bytes for a tsl_t and use the word that is properly aligned.
- */
-#define TSL_SET(tsl) tsl_set(tsl)
-#define TSL_UNSET(tsl) tsl_unset(tsl)
diff --git a/db2/mutex/uts4.cc.s b/db2/mutex/uts4_cc.s
index ee5f4143bd..ee5f4143bd 100644
--- a/db2/mutex/uts4.cc.s
+++ b/db2/mutex/uts4_cc.s