X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Futils%2Fmono-threads.h;h=0004e55c967954e437d6fcda1ec5e020bee49212;hb=c71c7fd1965b16a86d2b5ef2bd2b11cfdfff2294;hp=f2aa373f5c86b5e0e2c7b17bb4b496314b6c6d42;hpb=f78e6f8fee273c6c80c8c36e7e1b2bbd8392b8cb;p=mono.git diff --git a/mono/utils/mono-threads.h b/mono/utils/mono-threads.h index f2aa373f5c8..0004e55c967 100644 --- a/mono/utils/mono-threads.h +++ b/mono/utils/mono-threads.h @@ -13,9 +13,7 @@ #include #include #include - -/* FIXME used for CRITICAL_SECTION replace with mono-mutex */ -#include +#include #include @@ -98,8 +96,11 @@ typedef struct { MonoNativeThreadHandle native_handle; /* Valid on mach and android */ int thread_state; - /* suspend machinery, fields protected by the suspend_lock */ - CRITICAL_SECTION suspend_lock; + /*Tells if this thread was created by the runtime or not.*/ + gboolean runtime_thread; + + /* suspend machinery, fields protected by suspend_semaphore */ + MonoSemType suspend_semaphore; int suspend_count; MonoSemType finish_resume_semaphore; @@ -107,7 +108,9 @@ typedef struct { /* only needed by the posix backend */ #if (defined(_POSIX_VERSION) || defined(__native_client__)) && !defined (__MACH__) - MonoSemType suspend_semaphore; + MonoSemType begin_suspend_semaphore; + gboolean syscall_break_signal; + gboolean suspend_can_continue; #endif /*In theory, only the posix backend needs this, but having it on mach/win32 simplifies things a lot.*/ @@ -116,6 +119,13 @@ typedef struct { /*async call machinery, thread MUST be suspended before accessing those fields*/ void (*async_target)(void*); void *user_data; + + /* + If true, this thread is running a critical region of code and cannot be suspended. + A critical session is implicitly started when you call mono_thread_info_safe_suspend_sync + and is ended when you call either mono_thread_info_resume or mono_thread_info_finish_suspend. + */ + gboolean inside_critical_region; } MonoThreadInfo; typedef struct { @@ -141,13 +151,13 @@ typedef struct { /* Requires the world to be stoped */ -#define FOREACH_THREAD(thread) MONO_LLS_FOREACH (mono_thread_info_list_head (), thread) +#define FOREACH_THREAD(thread) MONO_LLS_FOREACH (mono_thread_info_list_head (), thread, SgenThreadInfo*) #define END_FOREACH_THREAD MONO_LLS_END_FOREACH /* Snapshot iteration. */ -#define FOREACH_THREAD_SAFE(thread) MONO_LLS_FOREACH_SAFE (mono_thread_info_list_head (), thread) +#define FOREACH_THREAD_SAFE(thread) MONO_LLS_FOREACH_SAFE (mono_thread_info_list_head (), thread, SgenThreadInfo*) #define END_FOREACH_THREAD_SAFE MONO_LLS_END_FOREACH_SAFE #define mono_thread_info_get_tid(info) ((MonoNativeThreadId)((MonoThreadInfo*)info)->node.key) @@ -196,6 +206,9 @@ mono_thread_info_safe_suspend_sync (MonoNativeThreadId tid, gboolean interrupt_k gboolean mono_thread_info_resume (MonoNativeThreadId tid) MONO_INTERNAL; +void +mono_thread_info_finish_suspend (void) MONO_INTERNAL; + void mono_thread_info_self_suspend (void) MONO_INTERNAL; @@ -217,6 +230,8 @@ mono_threads_unregister_current_thread (THREAD_INFO_TYPE *info) MONO_INTERNAL; void mono_thread_info_disable_new_interrupt (gboolean disable) MONO_INTERNAL; +void +mono_thread_info_abort_socket_syscall_for_close (MonoNativeThreadId tid) MONO_INTERNAL; #if !defined(HOST_WIN32) @@ -229,6 +244,12 @@ int mono_threads_pthread_kill (THREAD_INFO_TYPE *info, int signum) MONO_INTERNAL; #endif +#else /* !defined(HOST_WIN32) */ + +HANDLE + mono_threads_CreateThread (LPSECURITY_ATTRIBUTES attributes, SIZE_T stack_size, LPTHREAD_START_ROUTINE start_routine, LPVOID arg, DWORD creation_flags, LPDWORD thread_id); + + #endif /* !defined(HOST_WIN32) */ /* Plartform specific functions DON'T use them */ @@ -238,6 +259,8 @@ gboolean mono_threads_core_resume (MonoThreadInfo *info) MONO_INTERNAL; void mono_threads_platform_register (MonoThreadInfo *info) MONO_INTERNAL; //ok void mono_threads_platform_free (MonoThreadInfo *info) MONO_INTERNAL; void mono_threads_core_interrupt (MonoThreadInfo *info) MONO_INTERNAL; +void mono_threads_core_abort_syscall (MonoThreadInfo *info) MONO_INTERNAL; +gboolean mono_threads_core_needs_abort_syscall (void) MONO_INTERNAL; MonoNativeThreadId mono_native_thread_id_get (void) MONO_INTERNAL;