3574 assert(!thread->is_Java_thread() || Thread::current() == thread || Threads_lock->owned_by_self(), 3575 "possibility of dangling Thread pointer"); 3576 3577 OSThread* osthread = thread->osthread(); 3578 // There is no synchronization between the setting of the interrupt 3579 // and it being cleared here. It is critical - see 6535709 - that 3580 // we only clear the interrupt state, and reset the interrupt event, 3581 // if we are going to report that we were indeed interrupted - else 3582 // an interrupt can be "lost", leading to spurious wakeups or lost wakeups 3583 // depending on the timing. By checking thread interrupt event to see 3584 // if the thread gets real interrupt thus prevent spurious wakeup. 3585 bool interrupted = osthread->interrupted() && (WaitForSingleObject(osthread->interrupt_event(), 0) == WAIT_OBJECT_0); 3586 if (interrupted && clear_interrupted) { 3587 osthread->set_interrupted(false); 3588 ResetEvent(osthread->interrupt_event()); 3589 } // Otherwise leave the interrupted state alone 3590 3591 return interrupted; 3592 } 3593 3594 // Get's a pc (hint) for a running thread. Currently used only for profiling. 3595 ExtendedPC os::get_thread_pc(Thread* thread) { 3596 CONTEXT context; 3597 context.ContextFlags = CONTEXT_CONTROL; 3598 HANDLE handle = thread->osthread()->thread_handle(); 3599 if (GetThreadContext(handle, &context)) { 3600 #ifdef _M_AMD64 3601 return ExtendedPC((address) context.Rip); 3602 #else 3603 return ExtendedPC((address) context.Eip); 3604 #endif 3605 } else { 3606 return ExtendedPC(NULL); 3607 } 3608 } 3609 3610 // GetCurrentThreadId() returns DWORD 3611 intx os::current_thread_id() { return GetCurrentThreadId(); } 3612 3613 static int _initial_pid = 0; 3614 3615 int os::current_process_id() { 3616 return (_initial_pid ? _initial_pid : _getpid()); 3617 } 3618 3619 int os::win32::_vm_page_size = 0; 3620 int os::win32::_vm_allocation_granularity = 0; 3621 int os::win32::_processor_type = 0; 3622 // Processor level is not available on non-NT systems, use vm_version instead 3623 int os::win32::_processor_level = 0; 3624 julong os::win32::_physical_memory = 0; 3625 size_t os::win32::_default_stack_size = 0; 3626 3627 intx os::win32::_os_thread_limit = 0; 3628 volatile intx os::win32::_os_thread_count = 0; 3629 | 3574 assert(!thread->is_Java_thread() || Thread::current() == thread || Threads_lock->owned_by_self(), 3575 "possibility of dangling Thread pointer"); 3576 3577 OSThread* osthread = thread->osthread(); 3578 // There is no synchronization between the setting of the interrupt 3579 // and it being cleared here. It is critical - see 6535709 - that 3580 // we only clear the interrupt state, and reset the interrupt event, 3581 // if we are going to report that we were indeed interrupted - else 3582 // an interrupt can be "lost", leading to spurious wakeups or lost wakeups 3583 // depending on the timing. By checking thread interrupt event to see 3584 // if the thread gets real interrupt thus prevent spurious wakeup. 3585 bool interrupted = osthread->interrupted() && (WaitForSingleObject(osthread->interrupt_event(), 0) == WAIT_OBJECT_0); 3586 if (interrupted && clear_interrupted) { 3587 osthread->set_interrupted(false); 3588 ResetEvent(osthread->interrupt_event()); 3589 } // Otherwise leave the interrupted state alone 3590 3591 return interrupted; 3592 } 3593 3594 // GetCurrentThreadId() returns DWORD 3595 intx os::current_thread_id() { return GetCurrentThreadId(); } 3596 3597 static int _initial_pid = 0; 3598 3599 int os::current_process_id() { 3600 return (_initial_pid ? _initial_pid : _getpid()); 3601 } 3602 3603 int os::win32::_vm_page_size = 0; 3604 int os::win32::_vm_allocation_granularity = 0; 3605 int os::win32::_processor_type = 0; 3606 // Processor level is not available on non-NT systems, use vm_version instead 3607 int os::win32::_processor_level = 0; 3608 julong os::win32::_physical_memory = 0; 3609 size_t os::win32::_default_stack_size = 0; 3610 3611 intx os::win32::_os_thread_limit = 0; 3612 volatile intx os::win32::_os_thread_count = 0; 3613 |