static guint32 mono_alloc_static_data_slot (StaticDataInfo *static_data, guint32 size, guint32 align);
static gboolean mono_thread_resume (MonoThread* thread);
static void mono_thread_start (MonoThread *thread);
+static void signal_thread_state_change (MonoThread *thread);
/* Spin lock for InterlockedXXX 64 bit functions */
#define mono_interlocked_lock() EnterCriticalSection (&interlocked_mutex)
THREAD_DEBUG (g_message ("%s: Sleeping for %d ms", __func__, ms));
+ mono_thread_current_check_pending_interrupt ();
+
mono_monitor_enter (thread->synch_lock);
thread->state |= ThreadState_WaitSleepJoin;
mono_monitor_exit (thread->synch_lock);
mono_monitor_exit (thread->synch_lock);
}
+void ves_icall_System_Threading_Thread_SpinWait_internal (gint32 iterations)
+{
+ gint32 i;
+
+ for(i = 0; i < iterations; i++) {
+ /* We're busy waiting, but at least we can tell the
+ * scheduler to let someone else have a go...
+ */
+ Sleep (0);
+ }
+}
+
gint32
ves_icall_System_Threading_Thread_GetDomainID (void)
{
return FALSE;
}
+ mono_thread_current_check_pending_interrupt ();
+
this->state |= ThreadState_WaitSleepJoin;
mono_monitor_exit (this->synch_lock);
MONO_ARCH_SAVE_REGS;
+ /* Do this WaitSleepJoin check before creating objects */
+ mono_thread_current_check_pending_interrupt ();
+
numhandles = mono_array_length(mono_handles);
handles = g_new0(HANDLE, numhandles);
MONO_ARCH_SAVE_REGS;
+ /* Do this WaitSleepJoin check before creating objects */
+ mono_thread_current_check_pending_interrupt ();
+
numhandles = mono_array_length(mono_handles);
handles = g_new0(HANDLE, numhandles);
ms=INFINITE;
}
+ mono_thread_current_check_pending_interrupt ();
+
mono_monitor_enter (thread->synch_lock);
thread->state |= ThreadState_WaitSleepJoin;
mono_monitor_exit (thread->synch_lock);
return state;
}
+void ves_icall_System_Threading_Thread_Interrupt_internal (MonoThread *this)
+{
+ gboolean throw = FALSE;
+
+ mono_monitor_enter (this->synch_lock);
+
+ /* Clear out any previous request */
+ this->thread_interrupt_requested = FALSE;
+
+ if (this->state & ThreadState_WaitSleepJoin) {
+ throw = TRUE;
+ } else {
+ this->thread_interrupt_requested = TRUE;
+ }
+
+ mono_monitor_exit (this->synch_lock);
+
+ if (throw) {
+ signal_thread_state_change (this);
+ }
+}
+
+void mono_thread_current_check_pending_interrupt ()
+{
+ MonoThread *thread = mono_thread_current ();
+ gboolean throw = FALSE;
+
+ mono_monitor_enter (thread->synch_lock);
+
+ if (thread->thread_interrupt_requested) {
+ throw = TRUE;
+ thread->thread_interrupt_requested = FALSE;
+ }
+
+ mono_monitor_exit (thread->synch_lock);
+
+ if (throw) {
+ mono_raise_exception (mono_get_exception_thread_interrupted ());
+ }
+}
+
int
mono_thread_get_abort_signal (void)
{
}
thread->resume_event = CreateEvent (NULL, TRUE, FALSE, NULL);
+ if (thread->resume_event == NULL) {
+ mono_monitor_exit (thread->synch_lock);
+ return(FALSE);
+ }
/* Awake the thread */
SetEvent (thread->suspend_event);
InitializeCriticalSection(&interlocked_mutex);
InitializeCriticalSection(&contexts_mutex);
background_change_event = CreateEvent (NULL, TRUE, FALSE, NULL);
+ g_assert(background_change_event != NULL);
mono_init_static_data_info (&thread_static_info);
mono_init_static_data_info (&context_static_info);
thread->state |= ThreadState_SuspendRequested;
- if (thread->suspended_event == NULL)
+ if (thread->suspended_event == NULL) {
thread->suspended_event = CreateEvent (NULL, TRUE, FALSE, NULL);
+ if (thread->suspended_event == NULL) {
+ /* Forget this one and go on to the next */
+ mono_monitor_exit (thread->synch_lock);
+ continue;
+ }
+ }
events [eventidx++] = thread->suspended_event;
mono_monitor_exit (thread->synch_lock);
thread->state &= ~ThreadState_SuspendRequested;
thread->state |= ThreadState_Suspended;
thread->suspend_event = CreateEvent (NULL, TRUE, FALSE, NULL);
+ if (thread->suspend_event == NULL) {
+ mono_monitor_exit (thread->synch_lock);
+ return(NULL);
+ }
if (thread->suspended_event)
SetEvent (thread->suspended_event);
mono_monitor_exit (thread->synch_lock);
mono_monitor_exit (thread->synch_lock);
mono_thread_exit ();
return NULL;
+ } else if (thread->thread_interrupt_requested) {
+ mono_monitor_exit (thread->synch_lock);
+ return(mono_get_exception_thread_interrupted ());
}
mono_monitor_exit (thread->synch_lock);