void mono_threads_init (MonoThreadInfoCallbacks *callbacks, size_t info_size) { gboolean res; threads_callbacks = *callbacks; thread_info_size = info_size; #ifdef HOST_WIN32 res = mono_native_tls_alloc (&thread_info_key, NULL); #else res = mono_native_tls_alloc (&thread_info_key, unregister_thread); #endif g_assert (res); res = mono_native_tls_alloc (&small_id_key, NULL); g_assert (res); InitializeCriticalSection (&global_suspend_lock); mono_lls_init (&thread_list, NULL); mono_thread_smr_init (); mono_threads_init_platform (); mono_threads_inited = TRUE; g_assert (sizeof (MonoNativeThreadId) <= sizeof (uintptr_t)); }
void mono_threads_init (MonoThreadInfoCallbacks *callbacks, size_t info_size) { gboolean res; threads_callbacks = *callbacks; thread_info_size = info_size; #ifdef HOST_WIN32 res = mono_native_tls_alloc (&thread_info_key, NULL); #else res = mono_native_tls_alloc (&thread_info_key, unregister_thread); #endif g_assert (res); res = mono_native_tls_alloc (&small_id_key, NULL); g_assert (res); MONO_SEM_INIT (&global_suspend_semaphore, 1); mono_lls_init (&thread_list, NULL); mono_thread_smr_init (); mono_threads_init_platform (); #if defined(__MACH__) mono_mach_init (thread_info_key); #endif mono_threads_inited = TRUE; g_assert (sizeof (MonoNativeThreadId) <= sizeof (uintptr_t)); }
void mono_threads_init (MonoThreadInfoCallbacks *callbacks, size_t info_size) { gboolean res; threads_callbacks = *callbacks; thread_info_size = info_size; const char *sleepLimit; #ifdef HOST_WIN32 res = mono_native_tls_alloc (&thread_info_key, NULL); res = mono_native_tls_alloc (&thread_exited_key, NULL); #else res = mono_native_tls_alloc (&thread_info_key, (void *) thread_info_key_dtor); res = mono_native_tls_alloc (&thread_exited_key, (void *) thread_exited_dtor); #endif g_assert (res); #ifndef HAVE_KW_THREAD res = mono_native_tls_alloc (&small_id_key, NULL); #endif g_assert (res); unified_suspend_enabled = g_getenv ("MONO_ENABLE_UNIFIED_SUSPEND") != NULL || mono_threads_is_coop_enabled (); if ((sleepLimit = g_getenv ("MONO_SLEEP_ABORT_LIMIT")) != NULL) { errno = 0; long threshold = strtol(sleepLimit, NULL, 10); if ((errno == 0) && (threshold >= 40)) { sleepAbortDuration = threshold; sleepWarnDuration = threshold / 20; } else g_warning("MONO_SLEEP_ABORT_LIMIT must be a number >= 40"); } mono_os_sem_init (&global_suspend_semaphore, 1); mono_os_sem_init (&suspend_semaphore, 0); mono_lls_init (&thread_list, NULL, HAZARD_FREE_NO_LOCK); mono_thread_smr_init (); mono_threads_platform_init (); mono_threads_suspend_init (); mono_threads_coop_init (); mono_threads_abort_syscall_init (); #if defined(__MACH__) mono_mach_init (thread_info_key); #endif mono_threads_inited = TRUE; g_assert (sizeof (MonoNativeThreadId) <= sizeof (uintptr_t)); }
void mono_tls_init_runtime_keys (void) { #ifdef MONO_KEYWORD_THREAD MONO_THREAD_VAR_OFFSET (mono_tls_thread, tls_offsets [TLS_KEY_THREAD]); MONO_THREAD_VAR_OFFSET (mono_tls_jit_tls, tls_offsets [TLS_KEY_JIT_TLS]); MONO_THREAD_VAR_OFFSET (mono_tls_domain, tls_offsets [TLS_KEY_DOMAIN]); MONO_THREAD_VAR_OFFSET (mono_tls_lmf_addr, tls_offsets [TLS_KEY_LMF_ADDR]); #else mono_native_tls_alloc (&mono_tls_key_thread, NULL); MONO_THREAD_VAR_OFFSET (mono_tls_key_thread, tls_offsets [TLS_KEY_THREAD]); mono_native_tls_alloc (&mono_tls_key_jit_tls, NULL); MONO_THREAD_VAR_OFFSET (mono_tls_key_jit_tls, tls_offsets [TLS_KEY_JIT_TLS]); mono_native_tls_alloc (&mono_tls_key_domain, NULL); MONO_THREAD_VAR_OFFSET (mono_tls_key_domain, tls_offsets [TLS_KEY_DOMAIN]); mono_native_tls_alloc (&mono_tls_key_lmf_addr, NULL); MONO_THREAD_VAR_OFFSET (mono_tls_key_lmf_addr, tls_offsets [TLS_KEY_LMF_ADDR]); #endif }
void mono_tls_init_gc_keys (void) { #ifdef MONO_KEYWORD_THREAD MONO_THREAD_VAR_OFFSET (mono_tls_sgen_thread_info, tls_offsets [TLS_KEY_SGEN_THREAD_INFO]); #else mono_native_tls_alloc (&mono_tls_key_sgen_thread_info, NULL); MONO_THREAD_VAR_OFFSET (mono_tls_key_sgen_thread_info, tls_offsets [TLS_KEY_SGEN_THREAD_INFO]); #endif }
void mono_threads_init (MonoThreadInfoCallbacks *callbacks, size_t info_size) { gboolean res; threads_callbacks = *callbacks; thread_info_size = info_size; #ifdef HOST_WIN32 res = mono_native_tls_alloc (&thread_info_key, NULL); res = mono_native_tls_alloc (&thread_exited_key, NULL); #else res = mono_native_tls_alloc (&thread_info_key, (void *) unregister_thread); res = mono_native_tls_alloc (&thread_exited_key, (void *) thread_exited_dtor); #endif g_assert (res); #ifndef HAVE_KW_THREAD res = mono_native_tls_alloc (&small_id_key, NULL); #endif g_assert (res); unified_suspend_enabled = g_getenv ("MONO_ENABLE_UNIFIED_SUSPEND") != NULL || mono_threads_is_coop_enabled (); mono_coop_sem_init (&global_suspend_semaphore, 1); mono_os_sem_init (&suspend_semaphore, 0); mono_lls_init (&thread_list, NULL); mono_thread_smr_init (); mono_threads_init_platform (); mono_threads_init_coop (); mono_threads_init_abort_syscall (); #if defined(__MACH__) mono_mach_init (thread_info_key); #endif mono_threads_inited = TRUE; g_assert (sizeof (MonoNativeThreadId) <= sizeof (uintptr_t)); }
void mono_threads_coop_init (void) { if (!mono_threads_is_coop_enabled ()) return; mono_counters_register ("Coop Reset Blocking", MONO_COUNTER_GC | MONO_COUNTER_INT, &coop_reset_blocking_count); mono_counters_register ("Coop Try Blocking", MONO_COUNTER_GC | MONO_COUNTER_INT, &coop_try_blocking_count); mono_counters_register ("Coop Do Blocking", MONO_COUNTER_GC | MONO_COUNTER_INT, &coop_do_blocking_count); mono_counters_register ("Coop Do Polling", MONO_COUNTER_GC | MONO_COUNTER_INT, &coop_do_polling_count); mono_counters_register ("Coop Save Count", MONO_COUNTER_GC | MONO_COUNTER_INT, &coop_save_count); //See the above for what's wrong here. #ifdef ENABLE_CHECKED_BUILD_GC mono_native_tls_alloc (&coop_reset_count_stack_key, NULL); #endif }
void mono_sgen_ssb_init (SgenRemeberedSet *remset) { LOCK_INIT (global_remset_mutex); global_remset = mono_sgen_alloc_remset (1024, NULL, FALSE); global_remset->next = NULL; mono_native_tls_alloc (&remembered_set_key, NULL); #ifdef HEAVY_STATISTICS mono_counters_register ("WBarrier generic store stored", MONO_COUNTER_GC | MONO_COUNTER_INT, &stat_wbarrier_generic_store_remset); mono_counters_register ("Store remsets", MONO_COUNTER_GC | MONO_COUNTER_LONG, &stat_store_remsets); mono_counters_register ("Unique store remsets", MONO_COUNTER_GC | MONO_COUNTER_LONG, &stat_store_remsets_unique); mono_counters_register ("Saved remsets 1", MONO_COUNTER_GC | MONO_COUNTER_LONG, &stat_saved_remsets_1); mono_counters_register ("Saved remsets 2", MONO_COUNTER_GC | MONO_COUNTER_LONG, &stat_saved_remsets_2); mono_counters_register ("Non-global remsets processed", MONO_COUNTER_GC | MONO_COUNTER_LONG, &stat_local_remsets_processed); mono_counters_register ("Global remsets added", MONO_COUNTER_GC | MONO_COUNTER_LONG, &stat_global_remsets_added); mono_counters_register ("Global remsets re-added", MONO_COUNTER_GC | MONO_COUNTER_LONG, &stat_global_remsets_readded); mono_counters_register ("Global remsets processed", MONO_COUNTER_GC | MONO_COUNTER_LONG, &stat_global_remsets_processed); mono_counters_register ("Global remsets discarded", MONO_COUNTER_GC | MONO_COUNTER_LONG, &stat_global_remsets_discarded); #endif remset->wbarrier_set_field = mono_sgen_ssb_wbarrier_set_field; remset->wbarrier_set_arrayref = mono_sgen_ssb_wbarrier_set_arrayref; remset->wbarrier_arrayref_copy = mono_sgen_ssb_wbarrier_arrayref_copy; remset->wbarrier_value_copy = mono_sgen_ssb_wbarrier_value_copy; remset->wbarrier_object_copy = mono_sgen_ssb_wbarrier_object_copy; remset->wbarrier_generic_nostore = mono_sgen_ssb_wbarrier_generic_nostore; remset->record_pointer = mono_sgen_ssb_record_pointer; remset->begin_scan_remsets = mono_sgen_ssb_begin_scan_remsets; remset->finish_scan_remsets = mono_sgen_ssb_finish_scan_remsets; remset->register_thread = mono_sgen_ssb_register_thread; remset->cleanup_thread = mono_sgen_ssb_cleanup_thread; #ifdef HAVE_KW_THREAD remset->fill_thread_info_for_suspend = mono_sgen_ssb_fill_thread_info_for_suspend; #endif remset->prepare_for_minor_collection = mono_sgen_ssb_prepare_for_minor_collection; remset->prepare_for_major_collection = mono_sgen_ssb_prepare_for_major_collection; remset->find_address = mono_sgen_ssb_find_address; }
void checked_build_init (void) { mono_native_tls_alloc (&thread_status, NULL); }