Skip to content

Commit

Permalink
[threads] Add a global "runtime startup is finished" flag (dotnet#32668)
Browse files Browse the repository at this point in the history
This contributes to mono/mono#18916 (to make coop locking not bother with state transitions if the runtime isn't ready yet) .

Co-authored-by: Aleksey Kliger (λgeek) <[email protected]>
  • Loading branch information
monojenkins and lambdageek authored Mar 3, 2020
1 parent 200de97 commit 7224539
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/mono/mono/mini/mini-runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -4389,6 +4389,7 @@ mini_init (const char *filename, const char *runtime_version)
mono_thread_attach (domain);
MONO_PROFILER_RAISE (thread_name, (MONO_NATIVE_THREAD_ID_TO_UINT (mono_native_thread_id_get ()), "Main"));
#endif
mono_threads_set_runtime_startup_finished ();

#ifdef ENABLE_EXPERIMENT_TIERED
if (!mono_compile_aot) {
Expand Down
8 changes: 8 additions & 0 deletions src/mono/mono/utils/mono-threads-coop.c
Original file line number Diff line number Diff line change
Expand Up @@ -794,3 +794,11 @@ mono_thread_get_coop_aware (void)

return result;
}

char mono_threads_is_runtime_startup_finished_hidden_do_not_modify;

void
mono_threads_set_runtime_startup_finished (void)
{
mono_threads_is_runtime_startup_finished_hidden_do_not_modify = 1;
}
11 changes: 11 additions & 0 deletions src/mono/mono/utils/mono-threads-coop.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,15 @@ G_EXTERN_C // due to THREAD_INFO_TYPE varying
gpointer
mono_threads_enter_gc_unsafe_region_unbalanced_with_info (THREAD_INFO_TYPE *info, MonoStackData *stackdata);

extern char mono_threads_is_runtime_startup_finished_hidden_do_not_modify;

static inline gboolean
mono_threads_is_runtime_startup_finished (void)
{
return mono_threads_is_runtime_startup_finished_hidden_do_not_modify != 0;
}

void
mono_threads_set_runtime_startup_finished (void);

#endif

0 comments on commit 7224539

Please sign in to comment.