aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2002-09-21 00:14:05 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2002-09-21 00:14:05 +0000
commit7233aae50bea503369b0a4ef9a3b6a3864c96812 (patch)
tree74e622e1a18f007a7c595c1305599245038bfc3f
parentb2735fcd523cbb10851c7752cd9ce2709e8763eb (diff)
downloadpostgresql-7233aae50bea503369b0a4ef9a3b6a3864c96812.tar.gz
postgresql-7233aae50bea503369b0a4ef9a3b6a3864c96812.zip
Fix PPC s_lock operations to work correctly on multi-CPU machines.
Need 'isync' during TAS and 'sync' during S_UNLOCK.
-rw-r--r--src/backend/storage/lmgr/s_lock.c7
-rw-r--r--src/include/storage/s_lock.h17
2 files changed, 22 insertions, 2 deletions
diff --git a/src/backend/storage/lmgr/s_lock.c b/src/backend/storage/lmgr/s_lock.c
index 3d1f2a616e8..0d30203a5f3 100644
--- a/src/backend/storage/lmgr/s_lock.c
+++ b/src/backend/storage/lmgr/s_lock.c
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/s_lock.c,v 1.8 2002/06/20 20:29:35 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/s_lock.c,v 1.9 2002/09/21 00:14:05 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -115,6 +115,9 @@ _success: \n\
/* used in darwin. */
/* We key off __APPLE__ here because this function differs from
* the LinuxPPC implementation only in compiler syntax.
+ *
+ * NOTE: per the Enhanced PowerPC Architecture manual, v1.0 dated 7-May-2002,
+ * an isync is a sufficient synchronization barrier after a lwarx/stwcx loop.
*/
static void
tas_dummy()
@@ -134,6 +137,7 @@ tas: \n\
fail: li r3,1 \n\
blr \n\
success: \n\
+ isync \n\
li r3,0 \n\
blr \n\
");
@@ -158,6 +162,7 @@ tas: \n\
fail: li 3,1 \n\
blr \n\
success: \n\
+ isync \n\
li 3,0 \n\
blr \n\
");
diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h
index 374c0f260fa..1174b13694e 100644
--- a/src/include/storage/s_lock.h
+++ b/src/include/storage/s_lock.h
@@ -63,7 +63,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: s_lock.h,v 1.100 2002/09/02 04:42:52 momjian Exp $
+ * $Id: s_lock.h,v 1.101 2002/09/21 00:14:05 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -217,6 +217,21 @@ tas(volatile slock_t *lock)
#endif /* defined(__mc68000__) && defined(__linux__) */
+#if defined(__ppc__) || defined(__powerpc__)
+/*
+ * We currently use out-of-line assembler for TAS on PowerPC; see s_lock.c.
+ * S_UNLOCK is almost standard but requires a "sync" instruction.
+ */
+#define S_UNLOCK(lock) \
+do \
+{\
+ __asm__ __volatile__ (" sync \n"); \
+ *((volatile slock_t *) (lock)) = 0; \
+} while (0)
+
+#endif /* defined(__ppc__) || defined(__powerpc__) */
+
+
#if defined(NEED_VAX_TAS_ASM)
/*
* VAXen -- even multiprocessor ones