Exemple #1
0
static DWORD WINAPI
inner_start_thread (LPVOID arg)
{
	ThreadStartInfo *start_info = arg;
	void *t_arg = start_info->arg;
	int post_result;
	LPTHREAD_START_ROUTINE start_func = start_info->start_routine;
	DWORD result;
	gboolean suspend = start_info->suspend;
	HANDLE suspend_event = start_info->suspend_event;
	MonoThreadInfo *info;

	info = mono_thread_info_attach (&result);
	info->runtime_thread = TRUE;
	info->create_suspended = suspend;

	post_result = mono_coop_sem_post (&(start_info->registered));
	g_assert (!post_result);

	if (suspend) {
		WaitForSingleObject (suspend_event, INFINITE); /* caller will suspend the thread before setting the event. */
		CloseHandle (suspend_event);
	}

	result = start_func (t_arg);

	mono_thread_info_detach ();

	return result;
}
Exemple #2
0
static gsize WINAPI
inner_start_thread (gpointer data)
{
	CreateThreadData *thread_data;
	MonoThreadInfo *info;
	MonoThreadStart start_routine;
	gpointer start_routine_arg;
	gsize start_routine_res;
	gsize dummy;

	thread_data = (CreateThreadData*) data;
	g_assert (thread_data);

	start_routine = thread_data->start_routine;
	start_routine_arg = thread_data->start_routine_arg;

	info = mono_thread_info_attach (&dummy);
	info->runtime_thread = TRUE;

	thread_data->handle = mono_threads_open_thread_handle (info->handle);

	mono_coop_sem_post (&thread_data->registered);

	mono_refcount_dec (thread_data);

	/* thread_data is not valid anymore */
	thread_data = NULL;

	/* Run the actual main function of the thread */
	start_routine_res = start_routine (start_routine_arg);

	mono_thread_info_exit (start_routine_res);

	g_assert_not_reached ();
}
Exemple #3
0
static gsize WINAPI
inner_start_thread (gpointer data)
{
	CreateThreadData *thread_data;
	MonoThreadInfo *info;
	MonoThreadStart start_routine;
	gpointer start_routine_arg;
	guint32 start_routine_res;
	gint32 priority;
	gsize dummy;

	thread_data = (CreateThreadData*) data;
	g_assert (thread_data);

	start_routine = thread_data->start_routine;
	start_routine_arg = thread_data->start_routine_arg;

	priority = thread_data->priority;

	info = mono_thread_info_attach (&dummy);
	info->runtime_thread = TRUE;

	mono_threads_platform_set_priority (info, priority);

	thread_data->handle = mono_thread_info_duplicate_handle (info);

	mono_coop_sem_post (&thread_data->registered);

	if (InterlockedDecrement (&thread_data->ref) == 0) {
		mono_coop_sem_destroy (&thread_data->registered);
		g_free (thread_data);
	}

	/* thread_data is not valid anymore */
	thread_data = NULL;

	/* Run the actual main function of the thread */
	start_routine_res = start_routine (start_routine_arg);

	mono_threads_platform_exit (start_routine_res);

	g_assert_not_reached ();
}
Exemple #4
0
void
mono_thread_info_suspend_unlock (void)
{
	mono_coop_sem_post (&global_suspend_semaphore);
}