diff src/os/linux/vm/os_linux.cpp @ 14291:5944dba4badc

8028280: ParkEvent leak when running modified runThese which only loads classes Summary: Use spin lock to manage ParkEvent and PlatformEvent free lists. Reviewed-by: dholmes, fparain
author dsimms
date Fri, 24 Jan 2014 09:28:47 +0100
parents c250880a6673
children b59507f713e0 8cfe6fdbb99a
line wrap: on
line diff
--- a/src/os/linux/vm/os_linux.cpp	Thu Jan 23 16:02:14 2014 -0500
+++ b/src/os/linux/vm/os_linux.cpp	Fri Jan 24 09:28:47 2014 +0100
@@ -3871,9 +3871,33 @@
   }
 }
 
-int os::naked_sleep() {
-  // %% make the sleep time an integer flag. for now use 1 millisec.
-  return os::sleep(Thread::current(), 1, false);
+//
+// Short sleep, direct OS call.
+//
+// Note: certain versions of Linux CFS scheduler (since 2.6.23) do not guarantee
+// sched_yield(2) will actually give up the CPU:
+//
+//   * Alone on this pariticular CPU, keeps running.
+//   * Before the introduction of "skip_buddy" with "compat_yield" disabled
+//     (pre 2.6.39).
+//
+// So calling this with 0 is an alternative.
+//
+void os::naked_short_sleep(jlong ms) {
+  struct timespec req;
+
+  assert(ms < 1000, "Un-interruptable sleep, short time use only");
+  req.tv_sec = 0;
+  if (ms > 0) {
+    req.tv_nsec = (ms % 1000) * 1000000;
+  }
+  else {
+    req.tv_nsec = 1;
+  }
+
+  nanosleep(&req, NULL);
+
+  return;
 }
 
 // Sleep forever; naked call to OS-specific sleep; use with CAUTION