2010-04-29 Geoff Norton <gnorton@novell.com>
authorGeoff Norton <grompf@sublimeintervention.com>
Thu, 29 Apr 2010 18:50:57 +0000 (18:50 -0000)
committerGeoff Norton <grompf@sublimeintervention.com>
Thu, 29 Apr 2010 18:50:57 +0000 (18:50 -0000)
* mono-spinlock.h: Remove
* wthreads.c: Don't spinlock here, use a mutex instead

svn path=/trunk/mono/; revision=156443

mono/io-layer/ChangeLog
mono/io-layer/mono-spinlock.h [deleted file]
mono/io-layer/wthreads.c

index 6897a93044dc027bfd5e26d26353ec402b1a1711..6cf064212bc73996aace611d551004efc61b1241 100644 (file)
@@ -1,3 +1,8 @@
+2010-04-29  Geoff Norton  <gnorton@novell.com>
+
+       * mono-spinlock.h: Remove
+       * wthreads.c: Don't spinlock here, use a mutex instead
+
 2010-04-26  Geoff Norton  <gnorton@novell.com>
 
        * processes.c: Fix this for 64-bit darwin.
diff --git a/mono/io-layer/mono-spinlock.h b/mono/io-layer/mono-spinlock.h
deleted file mode 100644 (file)
index 4c2cd80..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * mono-spinlock.h:  Lightweight spinlocks, for internal use only
- *
- * Author:
- *     Dick Porter (dick@ximian.com)
- *
- * (C) 2002 Ximian, Inc.
- * Copyright (c) 2002-2006 Novell, Inc.
- */
-
-#ifndef _WAPI_MONO_SPINLOCK_H_
-#define _WAPI_MONO_SPINLOCK_H_
-
-#include <glib.h>
-
-#include <mono/io-layer/wapi.h>
-
-#define MONO_SPIN_LOCK(lock)   while((InterlockedCompareExchange((gint32 *)&lock, 1, 0))!=0)
-#define MONO_SPIN_UNLOCK(lock) lock=0
-
-#endif /* _WAPI_MONO_SPINLOCK_H_ */
index 684f84629e1067ee5b7a12f042fbce4c12138b7a..3cfbfd1d2cd4db5d44379f35a12cd963ad75c80f 100644 (file)
@@ -26,7 +26,6 @@
 #include <mono/io-layer/misc-private.h>
 #include <mono/io-layer/mono-mutex.h>
 #include <mono/io-layer/thread-private.h>
-#include <mono/io-layer/mono-spinlock.h>
 #include <mono/io-layer/mutex-private.h>
 #include <mono/io-layer/atomic.h>
 
@@ -818,7 +817,7 @@ guint32 SuspendThread(gpointer handle)
 
 static pthread_key_t TLS_keys[TLS_MINIMUM_AVAILABLE];
 static gboolean TLS_used[TLS_MINIMUM_AVAILABLE]={FALSE};
-static guint32 TLS_spinlock=0;
+static pthread_mutex_t TLS_mutex = PTHREAD_MUTEX_INITIALIZER;
 
 guint32
 mono_pthread_key_for_tls (guint32 idx)
@@ -841,7 +840,7 @@ guint32 TlsAlloc(void)
        guint32 i;
        int thr_ret;
        
-       MONO_SPIN_LOCK (TLS_spinlock);
+       pthread_mutex_lock (&TLS_mutex);
        
        for(i=0; i<TLS_MINIMUM_AVAILABLE; i++) {
                if(TLS_used[i]==FALSE) {
@@ -849,7 +848,7 @@ guint32 TlsAlloc(void)
                        thr_ret = pthread_key_create(&TLS_keys[i], NULL);
                        g_assert (thr_ret == 0);
 
-                       MONO_SPIN_UNLOCK (TLS_spinlock);
+                       pthread_mutex_unlock (&TLS_mutex);
        
 #ifdef TLS_DEBUG
                        g_message ("%s: returning key %d", __func__, i);
@@ -859,7 +858,7 @@ guint32 TlsAlloc(void)
                }
        }
 
-       MONO_SPIN_UNLOCK (TLS_spinlock);
+       pthread_mutex_unlock (&TLS_mutex);
        
 #ifdef TLS_DEBUG
        g_message ("%s: out of indices", __func__);
@@ -888,10 +887,10 @@ gboolean TlsFree(guint32 idx)
        g_message ("%s: freeing key %d", __func__, idx);
 #endif
 
-       MONO_SPIN_LOCK (TLS_spinlock);
+       pthread_mutex_lock (&TLS_mutex);
        
        if(TLS_used[idx]==FALSE) {
-               MONO_SPIN_UNLOCK (TLS_spinlock);
+               pthread_mutex_unlock (&TLS_mutex);
 
                return(FALSE);
        }
@@ -900,7 +899,7 @@ gboolean TlsFree(guint32 idx)
        thr_ret = pthread_key_delete(TLS_keys[idx]);
        g_assert (thr_ret == 0);
        
-       MONO_SPIN_UNLOCK (TLS_spinlock);
+       pthread_mutex_unlock (&TLS_mutex);
        
        return(TRUE);
 }