< prev index next >

src/hotspot/os/windows/os_windows.cpp

Print this page

        

*** 610,620 **** if (interrupt_event == NULL) { delete osthread; return false; } osthread->set_interrupt_event(interrupt_event); ! osthread->set_interrupted(false); thread->set_osthread(osthread); if (stack_size == 0) { switch (thr_type) { --- 610,622 ---- if (interrupt_event == NULL) { delete osthread; return false; } osthread->set_interrupt_event(interrupt_event); ! // We don't call set_interrupted(false) as it will trip the assert in there ! // as we are not operating on the current thread. We don't need to call it ! // because the initial state is already correct. thread->set_osthread(osthread); if (stack_size == 0) { switch (thr_type) {
*** 682,692 **** os::print_memory_info(&st); } if (thread_handle == NULL) { // Need to clean up stuff we've allocated so far - CloseHandle(osthread->interrupt_event()); thread->set_osthread(NULL); delete osthread; return false; } --- 684,693 ----
*** 712,722 **** // but we can only really operate on the current thread. assert(Thread::current()->osthread() == osthread, "os::free_thread but not current thread"); CloseHandle(osthread->thread_handle()); - CloseHandle(osthread->interrupt_event()); delete osthread; } static jlong first_filetime; static jlong initial_performance_count; --- 713,722 ----
*** 3483,3493 **** // >1: Thread is still suspended. assert(ret != SYS_THREAD_ERROR, "StartThread failed"); // should propagate back } - // Short sleep, direct OS call. // // ms = 0, means allow others (if any) to run. // void os::naked_short_sleep(jlong ms) { --- 3483,3492 ----
*** 3591,3643 **** } *priority_ptr = os_prio; return OS_OK; } - void os::interrupt(Thread* thread) { - debug_only(Thread::check_for_dangling_thread_pointer(thread);) - assert(thread->is_Java_thread(), "invariant"); - JavaThread* jt = (JavaThread*) thread; - OSThread* osthread = thread->osthread(); - osthread->set_interrupted(true); - // More than one thread can get here with the same value of osthread, - // resulting in multiple notifications. We do, however, want the store - // to interrupted() to be visible to other threads before we post - // the interrupt event. - OrderAccess::release(); - SetEvent(osthread->interrupt_event()); - // For JSR166: unpark after setting status - jt->parker()->unpark(); - - ParkEvent * ev = thread->_ParkEvent; - if (ev != NULL) ev->unpark(); - - ev = jt->_SleepEvent; - if (ev != NULL) ev->unpark(); - } - - - bool os::is_interrupted(Thread* thread, bool clear_interrupted) { - debug_only(Thread::check_for_dangling_thread_pointer(thread);) - - OSThread* osthread = thread->osthread(); - // There is no synchronization between the setting of the interrupt - // and it being cleared here. It is critical - see 6535709 - that - // we only clear the interrupt state, and reset the interrupt event, - // if we are going to report that we were indeed interrupted - else - // an interrupt can be "lost", leading to spurious wakeups or lost wakeups - // depending on the timing. By checking thread interrupt event to see - // if the thread gets real interrupt thus prevent spurious wakeup. - bool interrupted = osthread->interrupted() && (WaitForSingleObject(osthread->interrupt_event(), 0) == WAIT_OBJECT_0); - if (interrupted && clear_interrupted) { - osthread->set_interrupted(false); - ResetEvent(osthread->interrupt_event()); - } // Otherwise leave the interrupted state alone - - return interrupted; - } - // GetCurrentThreadId() returns DWORD intx os::current_thread_id() { return GetCurrentThreadId(); } static int _initial_pid = 0; --- 3590,3599 ----
*** 5344,5354 **** } JavaThread* thread = JavaThread::current(); // Don't wait if interrupted or already triggered ! if (Thread::is_interrupted(thread, false) || WaitForSingleObject(_ParkEvent, 0) == WAIT_OBJECT_0) { ResetEvent(_ParkEvent); return; } else { ThreadBlockInVM tbivm(thread); --- 5300,5310 ---- } JavaThread* thread = JavaThread::current(); // Don't wait if interrupted or already triggered ! if (thread->is_interrupted(false) || WaitForSingleObject(_ParkEvent, 0) == WAIT_OBJECT_0) { ResetEvent(_ParkEvent); return; } else { ThreadBlockInVM tbivm(thread);
< prev index next >