[coop] Use mono_thread_info_usleep which transition to BLOCKING state
authorLudovic Henry <ludovic@xamarin.com>
Mon, 25 Jan 2016 21:43:47 +0000 (21:43 +0000)
committerLudovic Henry <ludovic@xamarin.com>
Mon, 25 Jan 2016 21:50:02 +0000 (21:50 +0000)
Because we could sleep for too long, while being in RUNNING state, the cooperative suspend would not finish in a timely manner. That would lead to the abort in `mono_threads_wait_pending_operations`.

mono/metadata/threadpool-ms-io.c
mono/sgen/sgen-fin-weak-hash.c
mono/sgen/sgen-gc.c
mono/utils/mono-threads.c

index 3c931eb7b3d1fee75441268c0ff174c930029ce9..11029082f8bda156b5a52d577f07c4a43e7fbbed 100644 (file)
@@ -539,7 +539,7 @@ cleanup (void)
 
        selector_thread_wakeup ();
        while (io_selector_running)
-               g_usleep (1000);
+               mono_thread_info_usleep (1000);
 
        mono_coop_mutex_destroy (&threadpool_io->updates_lock);
        mono_coop_cond_destroy (&threadpool_io->updates_cond);
index a8ffed926faca04cd3ac14f5d3138eb7a47b78b1..5130b1c6b3894de6727e094a73032dd045a6f42c 100644 (file)
@@ -451,7 +451,7 @@ add_stage_entry (int num_entries, volatile gint32 *next_entry, StageEntry *entri
                                 * This seems like a good value.  Determined by timing
                                 * sgen-weakref-stress.exe.
                                 */
-                               g_usleep (200);
+                               mono_thread_info_usleep (200);
                                HEAVY_STAT (++stat_wait_for_processing);
                        }
                        continue;
index 0af554a01ff502af0ae73946f84407bbb3094803..8c27decedcf0bcc877c034e49611677bf7c413fb 100644 (file)
@@ -2764,7 +2764,7 @@ sgen_gc_init (void)
                        return;
                case -1:
                        /* being inited by another thread */
-                       g_usleep (1000);
+                       mono_thread_info_usleep (1000);
                        break;
                case 0:
                        /* we will init it */
index e677ada8457e84592b1d7a4c61273de6635e71f9..0e67cd6605386a4fbcef76cb17a51763e404303f 100644 (file)
@@ -540,7 +540,7 @@ mono_threads_attach_tools_thread (void)
        g_assert (!mono_native_tls_get_value (thread_info_key));
        
        while (!mono_threads_inited) { 
-               g_usleep (10);
+               mono_thread_info_usleep (10);
        }
 
        info = mono_thread_info_attach (&dummy);