- /*
- * mono-threads.c: Coop threading
+/**
+ * \file
+ * Coop threading
*
* Author:
* Rodrigo Kumpera (kumpera@gmail.com)
static void
mono_threads_state_poll_with_info (MonoThreadInfo *info)
{
- g_assert (mono_threads_is_coop_enabled ());
+ g_assert (mono_threads_is_blocking_transition_enabled ());
++coop_do_polling_count;
{
gpointer cookie;
- if (!mono_threads_is_coop_enabled ())
+ if (!mono_threads_is_blocking_transition_enabled ())
return NULL;
cookie = mono_threads_enter_gc_safe_region_unbalanced_with_info (info, stackdata);
static gpointer
mono_threads_enter_gc_safe_region_unbalanced_with_info (MonoThreadInfo *info, gpointer *stackdata)
{
- if (!mono_threads_is_coop_enabled ())
+ if (!mono_threads_is_blocking_transition_enabled ())
return NULL;
++coop_do_blocking_count;
void
mono_threads_exit_gc_safe_region (gpointer cookie, gpointer *stackdata)
{
- if (!mono_threads_is_coop_enabled ())
+ if (!mono_threads_is_blocking_transition_enabled ())
return;
#ifdef ENABLE_CHECKED_BUILD_GC
{
MonoThreadInfo *info;
- if (!mono_threads_is_coop_enabled ())
+ if (!mono_threads_is_blocking_transition_enabled ())
return;
info = (MonoThreadInfo *)cookie;
{
gpointer cookie;
- if (!mono_threads_is_coop_enabled ())
+ if (!mono_threads_is_blocking_transition_enabled ())
return NULL;
cookie = mono_threads_enter_gc_unsafe_region_unbalanced_with_info (info, stackdata);
gpointer
mono_threads_enter_gc_unsafe_region_unbalanced_with_info (MonoThreadInfo *info, gpointer *stackdata)
{
- if (!mono_threads_is_coop_enabled ())
+ if (!mono_threads_is_blocking_transition_enabled ())
return NULL;
++coop_reset_blocking_count;
{
MonoThreadInfo *info;
- g_assert (mono_threads_is_coop_enabled ());
+ g_assert (mono_threads_is_blocking_transition_enabled ());
info = mono_thread_info_current_unchecked ();
void
mono_threads_exit_gc_unsafe_region (gpointer cookie, gpointer *stackdata)
{
- if (!mono_threads_is_coop_enabled ())
+ if (!mono_threads_is_blocking_transition_enabled ())
return;
#ifdef ENABLE_CHECKED_BUILD_GC
void
mono_threads_exit_gc_unsafe_region_unbalanced (gpointer cookie, gpointer *stackdata)
{
- if (!mono_threads_is_coop_enabled ())
+ if (!mono_threads_is_blocking_transition_enabled ())
return;
if (!cookie)
#else
static int is_coop_enabled = -1;
if (G_UNLIKELY (is_coop_enabled == -1))
- is_coop_enabled = g_getenv ("MONO_ENABLE_COOP") != NULL ? 1 : 0;
+ is_coop_enabled = g_hasenv ("MONO_ENABLE_COOP") ? 1 : 0;
return is_coop_enabled == 1;
#endif
}
+gboolean
+mono_threads_is_blocking_transition_enabled (void)
+{
+#if defined(USE_COOP_GC)
+ return TRUE;
+#else
+ static int is_blocking_transition_enabled = -1;
+ if (G_UNLIKELY (is_blocking_transition_enabled == -1))
+ is_blocking_transition_enabled = (g_hasenv ("MONO_ENABLE_COOP") || g_hasenv ("MONO_ENABLE_BLOCKING_TRANSITION")) ? 1 : 0;
+ return is_blocking_transition_enabled == 1;
+#endif
+}
+
void
mono_threads_coop_init (void)
{
- if (!mono_threads_is_coop_enabled ())
+ if (!mono_threads_is_coop_enabled () && !mono_threads_is_blocking_transition_enabled ())
return;
mono_counters_register ("Coop Reset Blocking", MONO_COUNTER_GC | MONO_COUNTER_INT, &coop_reset_blocking_count);