8043630: Method os::yield_all() should be removed

Reviewed-by: dholmes, dsimms
This commit is contained in:
Frederic Parain 2014-06-23 06:58:26 -07:00
parent d9a2dbc73b
commit 5507f2b476
9 changed files with 9 additions and 58 deletions

View File

@ -2812,13 +2812,6 @@ void os::yield() {
os::YieldResult os::NakedYield() { sched_yield(); return os::YIELD_UNKNOWN; }
void os::yield_all() {
// Yields to all threads, including threads with lower priorities
// Threads on Linux are all with same priority. The Solaris style
// os::yield_all() with nanosleep(1ms) is not necessary.
sched_yield();
}
////////////////////////////////////////////////////////////////////////////////
// thread priority support
@ -3075,7 +3068,7 @@ static bool do_suspend(OSThread* osthread) {
for (int n = 0; !osthread->sr.is_suspended(); n++) {
for (int i = 0; i < RANDOMLY_LARGE_INTEGER2 && !osthread->sr.is_suspended(); i++) {
os::yield_all();
os::yield();
}
// timeout, try to cancel the request
@ -3109,7 +3102,7 @@ static void do_resume(OSThread* osthread) {
if (sr_notify(osthread) == 0) {
for (int n = 0; n < RANDOMLY_LARGE_INTEGER && !osthread->sr.is_running(); n++) {
for (int i = 0; i < 100 && !osthread->sr.is_running(); i++) {
os::yield_all();
os::yield();
}
}
} else {

View File

@ -2600,13 +2600,6 @@ void os::yield() {
os::YieldResult os::NakedYield() { sched_yield(); return os::YIELD_UNKNOWN; }
void os::yield_all() {
// Yields to all threads, including threads with lower priorities
// Threads on Bsd are all with same priority. The Solaris style
// os::yield_all() with nanosleep(1ms) is not necessary.
sched_yield();
}
////////////////////////////////////////////////////////////////////////////////
// thread priority support

View File

@ -3795,13 +3795,6 @@ void os::yield() {
os::YieldResult os::NakedYield() { sched_yield(); return os::YIELD_UNKNOWN; }
void os::yield_all() {
// Yields to all threads, including threads with lower priorities
// Threads on Linux are all with same priority. The Solaris style
// os::yield_all() with nanosleep(1ms) is not necessary.
sched_yield();
}
////////////////////////////////////////////////////////////////////////////////
// thread priority support

View File

@ -3186,11 +3186,6 @@ void os::yield() {
os::YieldResult os::NakedYield() { thr_yield(); return os::YIELD_UNKNOWN; }
void os::yield_all() {
// Yields to all threads, including threads with lower priorities
os::sleep(Thread::current(), 1, false);
}
// Interface for setting lwp priorities. If we are using T2 libthread,
// which forces the use of BoundThreads or we manually set UseBoundThreads,
// all of our threads will be assigned to real lwp's. Using the thr_setprio

View File

@ -3526,11 +3526,6 @@ os::YieldResult os::NakedYield() {
void os::yield() { os::NakedYield(); }
void os::yield_all() {
// Yields to all threads, including threads with lower priorities
Sleep(1);
}
// Win32 only gives you access to seven real priorities at a time,
// so we compress Java's ten down to seven. It would be better
// if we dynamically adjusted relative priorities.

View File

@ -3336,13 +3336,7 @@ static bool initializeDirectBufferSupport(JNIEnv* env, JavaThread* thread) {
directBufferSupportInitializeEnded = 1;
} else {
while (!directBufferSupportInitializeEnded && !directBufferSupportInitializeFailed) {
// Set state as yield_all can call os:sleep. On Solaris, yield_all calls
// os::sleep which requires the VM state transition. On other platforms, it
// is not necessary. The following call to change the VM state is purposely
// put inside the loop to avoid potential deadlock when multiple threads
// try to call this method. See 6791815 for more details.
ThreadInVMfromNative tivn(thread);
os::yield_all();
os::yield();
}
}

View File

@ -453,8 +453,6 @@ class os: AllStatic {
// yield that can be used in lieu of blocking.
} ;
static YieldResult NakedYield () ;
static void yield_all(); // Yields to all other threads including lower priority
// (for the default scheduling policy)
static OSReturn set_priority(Thread* thread, ThreadPriority priority);
static OSReturn get_priority(const Thread* const thread, ThreadPriority& priority);

View File

@ -264,8 +264,8 @@ void SafepointSynchronize::begin() {
//
// Further complicating matters is that yield() does not work as naively expected
// on many platforms -- yield() does not guarantee that any other ready threads
// will run. As such we revert yield_all() after some number of iterations.
// Yield_all() is implemented as a short unconditional sleep on some platforms.
// will run. As such we revert to naked_short_sleep() after some number of iterations.
// nakes_short_sleep() is implemented as a short unconditional sleep.
// Typical operating systems round a "short" sleep period up to 10 msecs, so sleeping
// can actually increase the time it takes the VM thread to detect that a system-wide
// stop-the-world safepoint has been reached. In a pathological scenario such as that
@ -322,9 +322,7 @@ void SafepointSynchronize::begin() {
if (steps < DeferThrSuspendLoopCount) {
os::NakedYield() ;
} else {
os::yield_all() ;
// Alternately, the VM thread could transiently depress its scheduling priority or
// transiently increase the priority of the tardy mutator(s).
os::naked_short_sleep(1);
}
iterations ++ ;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -481,17 +481,9 @@ class MemTracker : AllStatic {
if (_slowdown_calling_thread && thr != _worker_thread) {
#ifdef _WINDOWS
// On Windows, os::NakedYield() does not work as well
// as os::yield_all()
os::yield_all();
// as short sleep.
os::naked_short_sleep(1);
#else
// On Solaris, os::yield_all() depends on os::sleep()
// which requires JavaTherad in _thread_in_vm state.
// Transits thread to _thread_in_vm state can be dangerous
// if caller holds lock, as it may deadlock with Threads_lock.
// So use NaKedYield instead.
//
// Linux and BSD, NakedYield() and yield_all() implementations
// are the same.
os::NakedYield();
#endif
}