about summary refs log tree commit diff
path: root/linuxthreads
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-06-20 04:46:22 +0000
committerUlrich Drepper <drepper@redhat.com>2000-06-20 04:46:22 +0000
commitba80a015ee80c01be5100b8b94794b8784aa562b (patch)
tree7bb6db1e6fa726246c08346ce0732e393f174450 /linuxthreads
parentea97f90c9a84ce5c8a7c60695f05adfd2b6bb295 (diff)
downloadglibc-ba80a015ee80c01be5100b8b94794b8784aa562b.tar.gz
glibc-ba80a015ee80c01be5100b8b94794b8784aa562b.tar.xz
glibc-ba80a015ee80c01be5100b8b94794b8784aa562b.zip
Update.
	* malloc/Makefile: Change all references to memprof into memusage.
	* malloc/memprof.c: Rename to...
	* malloc/memusage.c: ...this.  New file.
	* malloc/memprof.sh: Rename to...
	* malloc/memusage.sh: ...this.  New file.
	* malloc/memprofstat.c: Rename to...
	* malloc/memusagestat.c: ...this.  New file.
Diffstat (limited to 'linuxthreads')
-rw-r--r--linuxthreads/ChangeLog12
-rw-r--r--linuxthreads/spinlock.c10
-rw-r--r--linuxthreads/spinlock.h35
3 files changed, 53 insertions, 4 deletions
diff --git a/linuxthreads/ChangeLog b/linuxthreads/ChangeLog
index 0402c0fdfe..b79ee3f43e 100644
--- a/linuxthreads/ChangeLog
+++ b/linuxthreads/ChangeLog
@@ -1,3 +1,15 @@
+2000-06-19  H.J. Lu  <hjl@gnu.org>
+
+	* spinlock.h (HAS_COMPARE_AND_SWAP): Defined if
+	HAS_COMPARE_AND_SWAP_WITH_RELEASE_SEMANTICS is defined.
+	(compare_and_swap_with_release_semantics): New. Default to
+	compare_and_swap if HAS_COMPARE_AND_SWAP_WITH_RELEASE_SEMANTICS
+	is not defined.
+
+	* spinlock.c (__pthread_unlock): Call
+	compare_and_swap_with_release_semantics () instead of
+	compare_and_swap ().
+
 2000-06-19  Ulrich Drepper  <drepper@redhat.com>
 
 	* sysdeps/pthread/timer_create.c: Use _set_errno instead of assigning
diff --git a/linuxthreads/spinlock.c b/linuxthreads/spinlock.c
index 3f5b8233b0..60d056aada 100644
--- a/linuxthreads/spinlock.c
+++ b/linuxthreads/spinlock.c
@@ -95,7 +95,9 @@ again:
     /* No threads are waiting for this lock.  Please note that we also
        enter this case if the lock is not taken at all.  If this wouldn't
        be done here we would crash further down.  */
-    if (! compare_and_swap(&lock->__status, oldstatus, 0, &lock->__spinlock))
+    if (! compare_and_swap_with_release_semantics (&lock->__status,
+						   oldstatus, 0,
+						   &lock->__spinlock))
       goto again;
     return 0;
   }
@@ -126,9 +128,9 @@ again:
     /* If max prio thread is at head, remove it with compare-and-swap
        to guard against concurrent lock operation */
     thr = (pthread_descr) oldstatus;
-    if (! compare_and_swap(&lock->__status,
-                           oldstatus, (long)(thr->p_nextlock),
-                           &lock->__spinlock))
+    if (! compare_and_swap_with_release_semantics
+	    (&lock->__status, oldstatus, (long)(thr->p_nextlock),
+	     &lock->__spinlock))
       goto again;
   } else {
     /* No risk of concurrent access, remove max prio thread normally */
diff --git a/linuxthreads/spinlock.h b/linuxthreads/spinlock.h
index 96010e4636..d1da3c1094 100644
--- a/linuxthreads/spinlock.h
+++ b/linuxthreads/spinlock.h
@@ -12,6 +12,25 @@
 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        */
 /* GNU Library General Public License for more details.                 */
 
+
+/* There are 2 compare and swap synchronization primitives with
+   different semantics:
+
+	1. compare_and_swap, which has acquire semantics (i.e. it
+	completes befor subsequent writes.)
+	2. compare_and_swap_with_release_semantics, which has release
+	semantics (it completes after previous writes.)
+
+   For those platforms on which they are the same. HAS_COMPARE_AND_SWAP
+   should be defined. For those platforms on which they are different, 
+   HAS_COMPARE_AND_SWAP_WITH_RELEASE_SEMANTICS has to be defined.  */
+
+#ifndef HAS_COMPARE_AND_SWAP
+#ifdef HAS_COMPARE_AND_SWAP_WITH_RELEASE_SEMANTICS
+#define HAS_COMPARE_AND_SWAP
+#endif
+#endif
+
 #if defined(TEST_FOR_COMPARE_AND_SWAP)
 
 extern int __pthread_has_cas;
@@ -29,6 +48,18 @@ static inline int compare_and_swap(long * ptr, long oldval, long newval,
 
 #elif defined(HAS_COMPARE_AND_SWAP)
 
+#ifdef HAS_COMPARE_AND_SWAP_WITH_RELEASE_SEMANTICS
+
+static inline int
+compare_and_swap_with_release_semantics (long * ptr, long oldval,
+					 long newval, int * spinlock)
+{
+  return __compare_and_swap_with_release_semantics (ptr, oldval,
+						    newval);
+}
+
+#endif
+
 static inline int compare_and_swap(long * ptr, long oldval, long newval,
                                    int * spinlock)
 {
@@ -48,6 +79,10 @@ static inline int compare_and_swap(long * ptr, long oldval, long newval,
 
 #endif
 
+#ifndef HAS_COMPARE_AND_SWAP_WITH_RELEASE_SEMANTICS
+#define compare_and_swap_with_release_semantics compare_and_swap
+#endif
+
 /* Internal locks */
 
 extern void internal_function __pthread_lock(struct _pthread_fastlock * lock,