3 #if defined(HAVE_SGEN_GC) && defined(HOST_WIN32)
7 #include "metadata/sgen-gc.h"
8 #include "metadata/gc-internal.h"
11 mono_sgen_resume_thread (SgenThreadInfo *info)
13 DWORD id = mono_thread_info_get_tid (info);
14 HANDLE handle = OpenThread (THREAD_ALL_ACCESS, FALSE, id);
19 result = ResumeThread (handle);
20 g_assert (result != (DWORD)-1);
24 return result != (DWORD)-1;
28 mono_sgen_suspend_thread (SgenThreadInfo *info)
30 DWORD id = mono_thread_info_get_tid (info);
31 HANDLE handle = OpenThread (THREAD_ALL_ACCESS, FALSE, id);
37 result = SuspendThread (handle);
38 g_assert (result != (DWORD)-1);
39 if (result == (DWORD)-1) {
44 context.ContextFlags = CONTEXT_INTEGER | CONTEXT_CONTROL;
46 if (!GetThreadContext (handle, &context)) {
47 g_assert_not_reached ();
48 ResumeThread (handle);
53 g_assert (context.ContextFlags & CONTEXT_INTEGER);
54 g_assert (context.ContextFlags & CONTEXT_CONTROL);
58 info->stopped_domain = NULL; /* FIXME: implement! */
59 info->stopped_ip = (gpointer)context.Eip;
60 info->stack_start = (char*)context.Esp - REDZONE_SIZE;
62 info->regs [0] = context.Edi;
63 info->regs [1] = context.Esi;
64 info->regs [2] = context.Ebx;
65 info->regs [3] = context.Edx;
66 info->regs [4] = context.Ecx;
67 info->regs [5] = context.Eax;
68 info->regs [6] = context.Ebp;
69 info->regs [7] = context.Esp;
70 info->stopped_regs = &info->regs;
73 if (mono_gc_get_gc_callbacks ()->thread_suspend_func)
74 mono_gc_get_gc_callbacks ()->thread_suspend_func (info->runtime_data, NULL);
80 mono_sgen_wait_for_suspend_ack (int count)
82 /* Win32 suspend/resume is synchronous, so we don't need to wait for anything */
86 mono_sgen_thread_handshake (BOOL suspend)
89 SgenThreadInfo *current = mono_thread_info_current ();
92 FOREACH_THREAD_SAFE (info) {
96 g_assert (!info->doing_handshake);
97 info->doing_handshake = TRUE;
99 if (!mono_sgen_suspend_thread (info))
102 g_assert (info->doing_handshake);
103 info->doing_handshake = FALSE;
105 if (!mono_sgen_resume_thread (info))
110 } END_FOREACH_THREAD_SAFE
115 mono_sgen_os_init (void)
120 mono_gc_get_suspend_signal (void)