stablity fix for os_sleep. patchset 2 introduced a buggy version of

os_sleep based on nanosleep(). revert to patchset 1 version based on
poll(). fixes issues with large sleep values. okay pvalchev@
This commit is contained in:
kurt 2006-02-22 22:52:44 +00:00
parent 04c4c5f7e5
commit 1fe7cb2239
2 changed files with 65 additions and 6 deletions

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.12 2006/02/16 05:46:21 david Exp $
# $OpenBSD: Makefile,v 1.13 2006/02/22 22:52:44 kurt Exp $
ONLY_FOR_ARCHS= i386
@ -6,8 +6,8 @@ COMMENT= "Java2(TM) Standard Edition Dev Kit v${V}"
COMMENT-jre= "Java2(TM) Standard Edition Runtime Environment v${V}"
V= 1.5.0
DISTNAME= jdk-1_5_0
PKGNAME= jdk-${V}p8
PKGNAME-jre= jre-${V}p8
PKGNAME= jdk-${V}p9
PKGNAME-jre= jre-${V}p9
CATEGORIES= devel/jdk java

View File

@ -1,6 +1,6 @@
$OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.4 2005/11/30 02:21:32 kurt Exp $
--- hotspot/src/os/bsd/vm/os_bsd.cpp.orig Tue Nov 22 10:16:29 2005
+++ hotspot/src/os/bsd/vm/os_bsd.cpp Tue Nov 29 09:47:23 2005
$OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.5 2006/02/22 22:52:44 kurt Exp $
--- hotspot/src/os/bsd/vm/os_bsd.cpp.orig Thu Feb 16 11:07:32 2006
+++ hotspot/src/os/bsd/vm/os_bsd.cpp Thu Feb 16 11:11:42 2006
@@ -290,8 +290,15 @@ julong os::allocatable_physical_memory(j
// is not known at this point. Alignments will
// be at most to LargePageSizeInBytes. Protect
@ -37,3 +37,62 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.4 2005/11/30 02:21:32 kurt
#define EXTENSIONS_DIR "/lib/ext"
#define ENDORSED_DIR "/lib/endorsed"
@@ -1909,22 +1918,50 @@ char* os::reserve_memory_special(size_t
}
static int os_sleep(jlong millis, bool interruptible) {
- struct timespec t;
+ const jlong limit = INT_MAX;
+ jlong prevtime;
int res;
- t.tv_sec = millis / 1000L;
- t.tv_nsec = (millis % 1000L) * 1000000;
+ while (millis > limit) {
+ if ((res = os_sleep(limit, interruptible)) != OS_OK)
+ return res;
+ millis -= limit;
+ }
+
+ // Restart interrupted polls with new parameters until the proper delay
+ // has been completed.
+
+ prevtime = getTimeMillis();
+
+ while (millis > 0) {
+ jlong newtime;
+
if (!interruptible) {
- do {
- res = nanosleep(&t, &t);
- } while ((res == OS_ERR) && (errno == EINTR) && (t.tv_sec != 0 || t.tv_nsec != 0));
+ // Following assert fails for os::yield_all:
+ // assert(!thread->is_Java_thread(), "must not be java thread");
+ res = poll(NULL, 0, millis);
} else {
assert(Thread::current()->is_Java_thread(), "must be java thread");
- INTERRUPTIBLE_NORESTART_VM(nanosleep(&t, &t), res, os::Bsd::clear_interrupted);
+ INTERRUPTIBLE_NORESTART_VM(poll(NULL, 0, millis), res,
+ os::Bsd::clear_interrupted);
}
// INTERRUPTIBLE_NORESTART_VM returns res == OS_INTRPT for thread.Interrupt
- return res;
+ if((res == OS_ERR) && (errno == EINTR)) {
+ newtime = getTimeMillis();
+ assert(newtime >= prevtime, "time moving backwards");
+ /* Doing prevtime and newtime in microseconds doesn't help precision,
+ and trying to round up to avoid lost milliseconds can result in a
+ too-short delay. */
+ millis -= newtime - prevtime;
+ if(millis <= 0)
+ return OS_OK;
+ prevtime = newtime;
+ } else
+ return res;
+ }
+
+ return OS_OK;
}
int os::Bsd::naked_sleep() {