Exemplo n.º 1
0
static gboolean
begin_async_suspend (MonoThreadInfo *info, gboolean interrupt_kernel)
{
	if (mono_threads_is_coop_enabled ()) {
		/* There's nothing else to do after we async request the thread to suspend */
		mono_threads_add_to_pending_operation_set (info);
		return TRUE;
	}

	return mono_threads_core_begin_async_suspend (info, interrupt_kernel);
}
Exemplo n.º 2
0
gboolean
mono_thread_info_begin_suspend (MonoThreadInfo *info, gboolean interrupt_kernel)
{
	switch (mono_threads_transition_request_async_suspension (info)) {
	case AsyncSuspendAlreadySuspended:
		return TRUE;
	case AsyncSuspendWait:
		mono_threads_add_to_pending_operation_set (info);
		return TRUE;
	case AsyncSuspendInitSuspend:
		return mono_threads_core_begin_async_suspend (info, interrupt_kernel);
	default:
		g_assert_not_reached ();
	}
}
Exemplo n.º 3
0
/*
The return value is only valid until a matching mono_thread_info_resume is called
*/
static MonoThreadInfo*
mono_thread_info_suspend_sync (MonoNativeThreadId tid, gboolean interrupt_kernel, const char **error_condition)
{
	MonoThreadHazardPointers *hp = mono_hazard_pointer_get ();	
	MonoThreadInfo *info = mono_thread_info_lookup (tid); /*info on HP1*/
	if (!info) {
		*error_condition = "Thread not found";
		return NULL;
	}

	switch (mono_threads_transition_request_async_suspension (info)) {
	case AsyncSuspendAlreadySuspended:
		mono_hazard_pointer_clear (hp, 1); //XXX this is questionable we got to clean the suspend/resume nonsense of critical sections
		return info;
	case AsyncSuspendWait:
		mono_threads_add_to_pending_operation_set (info);
		break;
	case AsyncSuspendInitSuspend:
		if (!mono_threads_core_begin_async_suspend (info, interrupt_kernel)) {
			mono_hazard_pointer_clear (hp, 1);
			*error_condition = "Could not suspend thread";
			return NULL;
		}
	}

	//Wait for the pending suspend to finish
	mono_threads_wait_pending_operations ();

	if (!mono_threads_core_check_suspend_result (info)) {

		mono_hazard_pointer_clear (hp, 1);
		*error_condition = "Post suspend failed";
		return NULL;
	}
	return info;
}