changeset 6657:45831d971923

8043630: Method os::yield_all() should be removed Reviewed-by: dholmes, dsimms
author fparain
date Mon, 23 Jun 2014 06:58:26 -0700
parents 3acb22b10934
children 97e0bce5bc53
files src/os/aix/vm/os_aix.cpp src/os/bsd/vm/os_bsd.cpp src/os/linux/vm/os_linux.cpp src/os/solaris/vm/os_solaris.cpp src/os/windows/vm/os_windows.cpp src/share/vm/prims/jni.cpp src/share/vm/runtime/os.hpp src/share/vm/runtime/safepoint.cpp src/share/vm/services/memTracker.hpp
diffstat 9 files changed, 9 insertions(+), 58 deletions(-) [+]
line wrap: on
line diff
--- a/src/os/aix/vm/os_aix.cpp	Sun Jun 22 21:23:32 2014 -0400
+++ b/src/os/aix/vm/os_aix.cpp	Mon Jun 23 06:58:26 2014 -0700
@@ -2812,13 +2812,6 @@
 
 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 @@
 
   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 @@
     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 {
--- a/src/os/bsd/vm/os_bsd.cpp	Sun Jun 22 21:23:32 2014 -0400
+++ b/src/os/bsd/vm/os_bsd.cpp	Mon Jun 23 06:58:26 2014 -0700
@@ -2600,13 +2600,6 @@
 
 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
 
--- a/src/os/linux/vm/os_linux.cpp	Sun Jun 22 21:23:32 2014 -0400
+++ b/src/os/linux/vm/os_linux.cpp	Mon Jun 23 06:58:26 2014 -0700
@@ -3795,13 +3795,6 @@
 
 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
 
--- a/src/os/solaris/vm/os_solaris.cpp	Sun Jun 22 21:23:32 2014 -0400
+++ b/src/os/solaris/vm/os_solaris.cpp	Mon Jun 23 06:58:26 2014 -0700
@@ -3186,11 +3186,6 @@
 
 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
--- a/src/os/windows/vm/os_windows.cpp	Sun Jun 22 21:23:32 2014 -0400
+++ b/src/os/windows/vm/os_windows.cpp	Mon Jun 23 06:58:26 2014 -0700
@@ -3526,11 +3526,6 @@
 
 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.
--- a/src/share/vm/prims/jni.cpp	Sun Jun 22 21:23:32 2014 -0400
+++ b/src/share/vm/prims/jni.cpp	Mon Jun 23 06:58:26 2014 -0700
@@ -3336,13 +3336,7 @@
     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();
     }
   }
 
--- a/src/share/vm/runtime/os.hpp	Sun Jun 22 21:23:32 2014 -0400
+++ b/src/share/vm/runtime/os.hpp	Mon Jun 23 06:58:26 2014 -0700
@@ -453,8 +453,6 @@
     // 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);
 
--- a/src/share/vm/runtime/safepoint.cpp	Sun Jun 22 21:23:32 2014 -0400
+++ b/src/share/vm/runtime/safepoint.cpp	Mon Jun 23 06:58:26 2014 -0700
@@ -264,8 +264,8 @@
       //
       // 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 @@
       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 ++ ;
--- a/src/share/vm/services/memTracker.hpp	Sun Jun 22 21:23:32 2014 -0400
+++ b/src/share/vm/services/memTracker.hpp	Mon Jun 23 06:58:26 2014 -0700
@@ -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 @@
     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
     }