3592 if (!UseThreadPriorities) return OS_OK; 3593 bool ret = SetThreadPriority(thread->osthread()->thread_handle(), priority) != 0; 3594 return ret ? OS_OK : OS_ERR; 3595 } 3596 3597 OSReturn os::get_native_priority(const Thread* const thread, 3598 int* priority_ptr) { 3599 if (!UseThreadPriorities) { 3600 *priority_ptr = java_to_os_priority[NormPriority]; 3601 return OS_OK; 3602 } 3603 int os_prio = GetThreadPriority(thread->osthread()->thread_handle()); 3604 if (os_prio == THREAD_PRIORITY_ERROR_RETURN) { 3605 assert(false, "GetThreadPriority failed"); 3606 return OS_ERR; 3607 } 3608 *priority_ptr = os_prio; 3609 return OS_OK; 3610 } 3611 3612 3613 // Hint to the underlying OS that a task switch would not be good. 3614 // Void return because it's a hint and can fail. 3615 void os::hint_no_preempt() {} 3616 3617 void os::interrupt(Thread* thread) { 3618 debug_only(Thread::check_for_dangling_thread_pointer(thread);) 3619 3620 OSThread* osthread = thread->osthread(); 3621 osthread->set_interrupted(true); 3622 // More than one thread can get here with the same value of osthread, 3623 // resulting in multiple notifications. We do, however, want the store 3624 // to interrupted() to be visible to other threads before we post 3625 // the interrupt event. 3626 OrderAccess::release(); 3627 SetEvent(osthread->interrupt_event()); 3628 // For JSR166: unpark after setting status 3629 if (thread->is_Java_thread()) { 3630 ((JavaThread*)thread)->parker()->unpark(); 3631 } 3632 3633 ParkEvent * ev = thread->_ParkEvent; 3634 if (ev != NULL) ev->unpark(); 3635 } 3636 | 3592 if (!UseThreadPriorities) return OS_OK; 3593 bool ret = SetThreadPriority(thread->osthread()->thread_handle(), priority) != 0; 3594 return ret ? OS_OK : OS_ERR; 3595 } 3596 3597 OSReturn os::get_native_priority(const Thread* const thread, 3598 int* priority_ptr) { 3599 if (!UseThreadPriorities) { 3600 *priority_ptr = java_to_os_priority[NormPriority]; 3601 return OS_OK; 3602 } 3603 int os_prio = GetThreadPriority(thread->osthread()->thread_handle()); 3604 if (os_prio == THREAD_PRIORITY_ERROR_RETURN) { 3605 assert(false, "GetThreadPriority failed"); 3606 return OS_ERR; 3607 } 3608 *priority_ptr = os_prio; 3609 return OS_OK; 3610 } 3611 3612 void os::interrupt(Thread* thread) { 3613 debug_only(Thread::check_for_dangling_thread_pointer(thread);) 3614 3615 OSThread* osthread = thread->osthread(); 3616 osthread->set_interrupted(true); 3617 // More than one thread can get here with the same value of osthread, 3618 // resulting in multiple notifications. We do, however, want the store 3619 // to interrupted() to be visible to other threads before we post 3620 // the interrupt event. 3621 OrderAccess::release(); 3622 SetEvent(osthread->interrupt_event()); 3623 // For JSR166: unpark after setting status 3624 if (thread->is_Java_thread()) { 3625 ((JavaThread*)thread)->parker()->unpark(); 3626 } 3627 3628 ParkEvent * ev = thread->_ParkEvent; 3629 if (ev != NULL) ev->unpark(); 3630 } 3631 |