[threading] Add a global variable that is set while a global suspend is hapening.
authorRodrigo Kumpera <kumpera@gmail.com>
Thu, 16 Apr 2015 23:01:13 +0000 (19:01 -0400)
committerRodrigo Kumpera <kumpera@gmail.com>
Fri, 17 Apr 2015 19:20:53 +0000 (15:20 -0400)
This global var is meant to be used by JIT'd code to efficiently implement polling.

mono/utils/mono-threads-coop.c
mono/utils/mono-threads-coop.h
mono/utils/mono-threads-posix.c
mono/utils/mono-threads-windows.c
mono/utils/mono-threads.c
mono/utils/mono-threads.h

index f19021b5a564aeeec71f2d61e939a1bb1ed4768e..b44719109ffc277ad377942a4b219b21a92d8408 100644 (file)
@@ -19,6 +19,7 @@
 
 #ifdef USE_COOP_BACKEND
 
+volatile size_t mono_polling_required;
 
 void
 mono_threads_state_poll (void)
@@ -249,5 +250,17 @@ mono_threads_platform_register (MonoThreadInfo *info)
        //See the above for what's wrong here.
 }
 
+void
+mono_threads_core_begin_global_suspend (void)
+{
+       mono_polling_required = 1;
+}
+
+void
+mono_threads_core_end_global_suspend (void)
+{
+       mono_polling_required = 0;
+}
+
 
 #endif
\ No newline at end of file
index 8626288f3538cb7a0e5d2bf40287d702395ee90c..6eca0266dcfb897f4fbef80bdfd1bc58f9ecdb01 100644 (file)
@@ -58,6 +58,9 @@ void mono_threads_reset_blocking_end (void* cookie);
 void* mono_threads_try_prepare_blocking (void);
 void mono_threads_finish_try_blocking (void* cookie);
 
+/* JIT specific interface */
+extern volatile size_t mono_polling_required ;
+
 #else
 
 #define MONO_SUSPEND_CHECK do {        } while (0);
index 94f58cdc58eb71774ad5d9d9d8562c4c7f8e0ab7..19fd8b7c12e75f7836cf00dba1251002b96dd3c5 100644 (file)
@@ -635,6 +635,16 @@ mono_threads_platform_free (MonoThreadInfo *info)
 {
 }
 
+void
+mono_threads_core_begin_global_suspend (void)
+{
+}
+
+void
+mono_threads_core_end_global_suspend (void)
+{
+}
+
 #endif /*defined (USE_POSIX_BACKEND)*/
 
 #endif
index af7bee62097b4ba6b11f870e81fdf6ee41c251fb..b5008b4859eb3ae099d0e0631792b58934c525bb 100755 (executable)
@@ -407,4 +407,14 @@ mono_threads_core_clear_interruption (void)
 {
 }
 
+void
+mono_threads_core_begin_global_suspend (void)
+{
+}
+
+void
+mono_threads_core_end_global_suspend (void)
+{
+}
+
 #endif
index 814a8e457540e17df96f137328c16b4a9a94c9d9..bb9acf9103c102e70de1ff1abfbe404476303961 100644 (file)
@@ -123,6 +123,7 @@ mono_threads_begin_global_suspend (void)
 {
        g_assert (pending_suspends == 0);
        THREADS_SUSPEND_DEBUG ("------ BEGIN GLOBAL OP sp %d rp %d wd %d po %d\n", suspend_posts, resume_posts, waits_done, pending_ops);
+       mono_threads_core_begin_global_suspend ();
 }
 
 void
@@ -130,6 +131,7 @@ mono_threads_end_global_suspend (void)
 {
        g_assert (pending_suspends == 0);
        THREADS_SUSPEND_DEBUG ("------ END GLOBAL OP sp %d rp %d wd %d po %d\n", suspend_posts, resume_posts, waits_done, pending_ops);
+       mono_threads_core_end_global_suspend ();
 }
 
 static void
index a9a7b914baa82467bcafba122db688970492cb8f..f04543cb4cf7ddffa4d8341048738930eb38d826 100644 (file)
@@ -483,6 +483,9 @@ HANDLE mono_threads_core_open_handle (void);
 HANDLE mono_threads_core_open_thread_handle (HANDLE handle, MonoNativeThreadId tid);
 void mono_threads_core_set_name (MonoNativeThreadId tid, const char *name);
 
+void mono_threads_core_begin_global_suspend (void);
+void mono_threads_core_end_global_suspend (void);
+
 /* Internal API between mono-threads and its backends. */
 
 /* Backend functions - a backend must implement all of the following */