[coop] Switch SGen sgen_interruption_mutex to coop implementation
authorLudovic Henry <ludovic@xamarin.com>
Mon, 16 Nov 2015 17:00:49 +0000 (17:00 +0000)
committerLudovic Henry <ludovic@xamarin.com>
Thu, 19 Nov 2015 18:30:20 +0000 (18:30 +0000)
mono/sgen/sgen-gc.c
mono/sgen/sgen-gc.h

index 07af36570d1bf237f550e1961c6652ebfcfec1d3..d559a9285ee4fdea5299d0b674adaa01531c5a67 100644 (file)
@@ -359,7 +359,7 @@ GCMemSection *nursery_section = NULL;
 static volatile mword lowest_heap_address = ~(mword)0;
 static volatile mword highest_heap_address = 0;
 
-LOCK_DECLARE (sgen_interruption_mutex);
+MonoCoopMutex sgen_interruption_mutex;
 
 int current_collection_generation = -1;
 static volatile gboolean concurrent_collection_in_progress = FALSE;
@@ -2811,7 +2811,7 @@ sgen_gc_init (void)
 
        gc_debug_file = stderr;
 
-       LOCK_INIT (sgen_interruption_mutex);
+       mono_coop_mutex_init (&sgen_interruption_mutex);
 
        if ((env = g_getenv (MONO_GC_PARAMS_NAME))) {
                opts = g_strsplit (env, ",", -1);
index d7a42ce91ee09289922fb81f8de69371cb7cb82e..0b5d182ff4a4290444afa3d34372c103af041aa0 100644 (file)
@@ -40,6 +40,7 @@ typedef struct _SgenThreadInfo SgenThreadInfo;
 #include "mono/utils/mono-compiler.h"
 #include "mono/utils/atomic.h"
 #include "mono/utils/mono-os-mutex.h"
+#include "mono/utils/mono-coop-mutex.h"
 #include "mono/sgen/sgen-conf.h"
 #include "mono/sgen/sgen-hash-table.h"
 #include "mono/sgen/sgen-protocol.h"
@@ -93,15 +94,10 @@ struct _GCMemSection {
 #define LOCK_GC do { sgen_gc_lock (); } while (0)
 #define UNLOCK_GC do { sgen_gc_unlock (); } while (0)
 
-extern LOCK_DECLARE (sgen_interruption_mutex);
+extern MonoCoopMutex sgen_interruption_mutex;
 
-#define LOCK_INTERRUPTION do { \
-       MONO_TRY_BLOCKING       \
-       mono_os_mutex_lock (&sgen_interruption_mutex);  \
-       MONO_FINISH_TRY_BLOCKING        \
-} while (0)
-
-#define UNLOCK_INTERRUPTION mono_os_mutex_unlock (&sgen_interruption_mutex)
+#define LOCK_INTERRUPTION mono_coop_mutex_lock (&sgen_interruption_mutex)
+#define UNLOCK_INTERRUPTION mono_coop_mutex_unlock (&sgen_interruption_mutex)
 
 /* FIXME: Use InterlockedAdd & InterlockedAdd64 to reduce the CAS cost. */
 #define SGEN_CAS       InterlockedCompareExchange