comparison src/os/linux/vm/os_linux.cpp @ 14518:d8041d695d19

Merged with jdk9/dev/hotspot changeset 3812c088b945
author twisti
date Tue, 11 Mar 2014 18:45:59 -0700
parents 096c224171c4 bb9356ec5967
children b51e29501f30 4ca6dc0799b6
comparison
equal deleted inserted replaced
14141:f97c5ec83832 14518:d8041d695d19
1 /* 1 /*
2 * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
137 137
138 static int clock_tics_per_sec = 100; 138 static int clock_tics_per_sec = 100;
139 139
140 // For diagnostics to print a message once. see run_periodic_checks 140 // For diagnostics to print a message once. see run_periodic_checks
141 static sigset_t check_signal_done; 141 static sigset_t check_signal_done;
142 static bool check_signals = true;; 142 static bool check_signals = true;
143 143
144 static pid_t _initial_pid = 0; 144 static pid_t _initial_pid = 0;
145 145
146 /* Signal number used to suspend/resume a thread */ 146 /* Signal number used to suspend/resume a thread */
147 147
255 static char cpu_arch[] = "i386"; 255 static char cpu_arch[] = "i386";
256 #elif defined(AMD64) 256 #elif defined(AMD64)
257 static char cpu_arch[] = "amd64"; 257 static char cpu_arch[] = "amd64";
258 #elif defined(ARM) 258 #elif defined(ARM)
259 static char cpu_arch[] = "arm"; 259 static char cpu_arch[] = "arm";
260 #elif defined(PPC) 260 #elif defined(PPC32)
261 static char cpu_arch[] = "ppc"; 261 static char cpu_arch[] = "ppc";
262 #elif defined(PPC64)
263 static char cpu_arch[] = "ppc64";
262 #elif defined(SPARC) 264 #elif defined(SPARC)
263 # ifdef _LP64 265 # ifdef _LP64
264 static char cpu_arch[] = "sparcv9"; 266 static char cpu_arch[] = "sparcv9";
265 # else 267 # else
266 static char cpu_arch[] = "sparc"; 268 static char cpu_arch[] = "sparc";
528 sigemptyset(&allowdebug_blocked_sigs); 530 sigemptyset(&allowdebug_blocked_sigs);
529 sigaddset(&unblocked_sigs, SIGILL); 531 sigaddset(&unblocked_sigs, SIGILL);
530 sigaddset(&unblocked_sigs, SIGSEGV); 532 sigaddset(&unblocked_sigs, SIGSEGV);
531 sigaddset(&unblocked_sigs, SIGBUS); 533 sigaddset(&unblocked_sigs, SIGBUS);
532 sigaddset(&unblocked_sigs, SIGFPE); 534 sigaddset(&unblocked_sigs, SIGFPE);
535 #if defined(PPC64)
536 sigaddset(&unblocked_sigs, SIGTRAP);
537 #endif
533 sigaddset(&unblocked_sigs, SR_signum); 538 sigaddset(&unblocked_sigs, SR_signum);
534 539
535 if (!ReduceSignalUsage) { 540 if (!ReduceSignalUsage) {
536 if (!os::Linux::is_sig_ignored(SHUTDOWN1_SIGNAL)) { 541 if (!os::Linux::is_sig_ignored(SHUTDOWN1_SIGNAL)) {
537 sigaddset(&unblocked_sigs, SHUTDOWN1_SIGNAL); 542 sigaddset(&unblocked_sigs, SHUTDOWN1_SIGNAL);
1449 _pthread_getcpuclockid = pthread_getcpuclockid_func; 1454 _pthread_getcpuclockid = pthread_getcpuclockid_func;
1450 } 1455 }
1451 } 1456 }
1452 1457
1453 jlong os::javaTimeNanos() { 1458 jlong os::javaTimeNanos() {
1454 if (Linux::supports_monotonic_clock()) { 1459 if (os::supports_monotonic_clock()) {
1455 struct timespec tp; 1460 struct timespec tp;
1456 int status = Linux::clock_gettime(CLOCK_MONOTONIC, &tp); 1461 int status = Linux::clock_gettime(CLOCK_MONOTONIC, &tp);
1457 assert(status == 0, "gettime error"); 1462 assert(status == 0, "gettime error");
1458 jlong result = jlong(tp.tv_sec) * (1000 * 1000 * 1000) + jlong(tp.tv_nsec); 1463 jlong result = jlong(tp.tv_sec) * (1000 * 1000 * 1000) + jlong(tp.tv_nsec);
1459 return result; 1464 return result;
1465 return 1000 * usecs; 1470 return 1000 * usecs;
1466 } 1471 }
1467 } 1472 }
1468 1473
1469 void os::javaTimeNanos_info(jvmtiTimerInfo *info_ptr) { 1474 void os::javaTimeNanos_info(jvmtiTimerInfo *info_ptr) {
1470 if (Linux::supports_monotonic_clock()) { 1475 if (os::supports_monotonic_clock()) {
1471 info_ptr->max_value = ALL_64_BITS; 1476 info_ptr->max_value = ALL_64_BITS;
1472 1477
1473 // CLOCK_MONOTONIC - amount of time since some arbitrary point in the past 1478 // CLOCK_MONOTONIC - amount of time since some arbitrary point in the past
1474 info_ptr->may_skip_backward = false; // not subject to resetting or drifting 1479 info_ptr->may_skip_backward = false; // not subject to resetting or drifting
1475 info_ptr->may_skip_forward = false; // not subject to resetting or drifting 1480 info_ptr->may_skip_forward = false; // not subject to resetting or drifting
2102 void* res = dlsym(handle, name); 2107 void* res = dlsym(handle, name);
2103 pthread_mutex_unlock(&dl_mutex); 2108 pthread_mutex_unlock(&dl_mutex);
2104 return res; 2109 return res;
2105 } 2110 }
2106 2111
2112 void* os::get_default_process_handle() {
2113 return (void*)::dlopen(NULL, RTLD_LAZY);
2114 }
2107 2115
2108 static bool _print_ascii_file(const char* filename, outputStream* st) { 2116 static bool _print_ascii_file(const char* filename, outputStream* st) {
2109 int fd = ::open(filename, O_RDONLY); 2117 int fd = ::open(filename, O_RDONLY);
2110 if (fd == -1) { 2118 if (fd == -1) {
2111 return false; 2119 return false;
2255 st->print(" <Not Available>"); 2263 st->print(" <Not Available>");
2256 } 2264 }
2257 st->cr(); 2265 st->cr();
2258 } 2266 }
2259 2267
2260 // Taken from /usr/include/bits/siginfo.h Supposed to be architecture specific
2261 // but they're the same for all the linux arch that we support
2262 // and they're the same for solaris but there's no common place to put this.
2263 const char *ill_names[] = { "ILL0", "ILL_ILLOPC", "ILL_ILLOPN", "ILL_ILLADR",
2264 "ILL_ILLTRP", "ILL_PRVOPC", "ILL_PRVREG",
2265 "ILL_COPROC", "ILL_BADSTK" };
2266
2267 const char *fpe_names[] = { "FPE0", "FPE_INTDIV", "FPE_INTOVF", "FPE_FLTDIV",
2268 "FPE_FLTOVF", "FPE_FLTUND", "FPE_FLTRES",
2269 "FPE_FLTINV", "FPE_FLTSUB", "FPE_FLTDEN" };
2270
2271 const char *segv_names[] = { "SEGV0", "SEGV_MAPERR", "SEGV_ACCERR" };
2272
2273 const char *bus_names[] = { "BUS0", "BUS_ADRALN", "BUS_ADRERR", "BUS_OBJERR" };
2274
2275 void os::print_siginfo(outputStream* st, void* siginfo) { 2268 void os::print_siginfo(outputStream* st, void* siginfo) {
2276 st->print("siginfo:"); 2269 const siginfo_t* si = (const siginfo_t*)siginfo;
2277 2270
2278 const int buflen = 100; 2271 os::Posix::print_siginfo_brief(st, si);
2279 char buf[buflen]; 2272
2280 siginfo_t *si = (siginfo_t*)siginfo; 2273 if (si && (si->si_signo == SIGBUS || si->si_signo == SIGSEGV) &&
2281 st->print("si_signo=%s: ", os::exception_name(si->si_signo, buf, buflen));
2282 if (si->si_errno != 0 && strerror_r(si->si_errno, buf, buflen) == 0) {
2283 st->print("si_errno=%s", buf);
2284 } else {
2285 st->print("si_errno=%d", si->si_errno);
2286 }
2287 const int c = si->si_code;
2288 assert(c > 0, "unexpected si_code");
2289 switch (si->si_signo) {
2290 case SIGILL:
2291 st->print(", si_code=%d (%s)", c, c > 8 ? "" : ill_names[c]);
2292 st->print(", si_addr=" PTR_FORMAT, si->si_addr);
2293 break;
2294 case SIGFPE:
2295 st->print(", si_code=%d (%s)", c, c > 9 ? "" : fpe_names[c]);
2296 st->print(", si_addr=" PTR_FORMAT, si->si_addr);
2297 break;
2298 case SIGSEGV:
2299 st->print(", si_code=%d (%s)", c, c > 2 ? "" : segv_names[c]);
2300 st->print(", si_addr=" PTR_FORMAT, si->si_addr);
2301 break;
2302 case SIGBUS:
2303 st->print(", si_code=%d (%s)", c, c > 3 ? "" : bus_names[c]);
2304 st->print(", si_addr=" PTR_FORMAT, si->si_addr);
2305 break;
2306 default:
2307 st->print(", si_code=%d", si->si_code);
2308 // no si_addr
2309 }
2310
2311 if ((si->si_signo == SIGBUS || si->si_signo == SIGSEGV) &&
2312 UseSharedSpaces) { 2274 UseSharedSpaces) {
2313 FileMapInfo* mapinfo = FileMapInfo::current_info(); 2275 FileMapInfo* mapinfo = FileMapInfo::current_info();
2314 if (mapinfo->is_in_shared_space(si->si_addr)) { 2276 if (mapinfo->is_in_shared_space(si->si_addr)) {
2315 st->print("\n\nError accessing class data sharing archive." \ 2277 st->print("\n\nError accessing class data sharing archive." \
2316 " Mapped file inaccessible during execution, " \ 2278 " Mapped file inaccessible during execution, " \
2336 print_signal_handler(st, SR_signum, buf, buflen); 2298 print_signal_handler(st, SR_signum, buf, buflen);
2337 print_signal_handler(st, SHUTDOWN1_SIGNAL, buf, buflen); 2299 print_signal_handler(st, SHUTDOWN1_SIGNAL, buf, buflen);
2338 print_signal_handler(st, SHUTDOWN2_SIGNAL , buf, buflen); 2300 print_signal_handler(st, SHUTDOWN2_SIGNAL , buf, buflen);
2339 print_signal_handler(st, SHUTDOWN3_SIGNAL , buf, buflen); 2301 print_signal_handler(st, SHUTDOWN3_SIGNAL , buf, buflen);
2340 print_signal_handler(st, BREAK_SIGNAL, buf, buflen); 2302 print_signal_handler(st, BREAK_SIGNAL, buf, buflen);
2303 #if defined(PPC64)
2304 print_signal_handler(st, SIGTRAP, buf, buflen);
2305 #endif
2341 } 2306 }
2342 2307
2343 static char saved_jvm_path[MAXPATHLEN] = {0}; 2308 static char saved_jvm_path[MAXPATHLEN] = {0};
2344 2309
2345 // Find the full path to the current module, libjvm.so 2310 // Find the full path to the current module, libjvm.so
2366 rp = realpath(dli_fname, buf); 2331 rp = realpath(dli_fname, buf);
2367 } 2332 }
2368 if (rp == NULL) 2333 if (rp == NULL)
2369 return; 2334 return;
2370 2335
2371 if (Arguments::created_by_gamma_launcher()) { 2336 if (Arguments::sun_java_launcher_is_altjvm()) {
2372 // Support for the gamma launcher. Typical value for buf is 2337 // Support for the java launcher's '-XXaltjvm=<path>' option. Typical
2373 // "<JAVA_HOME>/jre/lib/<arch>/<vmtype>/libjvm.so". If "/jre/lib/" appears at 2338 // value for buf is "<JAVA_HOME>/jre/lib/<arch>/<vmtype>/libjvm.so".
2374 // the right place in the string, then assume we are installed in a JDK and 2339 // If "/jre/lib/" appears at the right place in the string, then
2375 // we're done. Otherwise, check for a JAVA_HOME environment variable and fix 2340 // assume we are installed in a JDK and we're done. Otherwise, check
2376 // up the path so it looks like libjvm.so is installed there (append a 2341 // for a JAVA_HOME environment variable and fix up the path so it
2377 // fake suffix hotspot/libjvm.so). 2342 // looks like libjvm.so is installed there (append a fake suffix
2343 // hotspot/libjvm.so).
2378 const char *p = buf + strlen(buf) - 1; 2344 const char *p = buf + strlen(buf) - 1;
2379 for (int count = 0; p > buf && count < 5; ++count) { 2345 for (int count = 0; p > buf && count < 5; ++count) {
2380 for (--p; p > buf && *p != '/'; --p) 2346 for (--p; p > buf && *p != '/'; --p)
2381 /* empty */ ; 2347 /* empty */ ;
2382 } 2348 }
2994 size_t page_sz = os::vm_page_size(); 2960 size_t page_sz = os::vm_page_size();
2995 unsigned pages = size / page_sz; 2961 unsigned pages = size / page_sz;
2996 2962
2997 unsigned char vec[1]; 2963 unsigned char vec[1];
2998 unsigned imin = 1, imax = pages + 1, imid; 2964 unsigned imin = 1, imax = pages + 1, imid;
2999 int mincore_return_value; 2965 int mincore_return_value = 0;
2966
2967 assert(imin <= imax, "Unexpected page size");
3000 2968
3001 while (imin < imax) { 2969 while (imin < imax) {
3002 imid = (imax + imin) / 2; 2970 imid = (imax + imin) / 2;
3003 nbot = ntop - (imid * page_sz); 2971 nbot = ntop - (imid * page_sz);
3004 2972
3787 3755
3788 size_t os::read(int fd, void *buf, unsigned int nBytes) { 3756 size_t os::read(int fd, void *buf, unsigned int nBytes) {
3789 return ::read(fd, buf, nBytes); 3757 return ::read(fd, buf, nBytes);
3790 } 3758 }
3791 3759
3792 // TODO-FIXME: reconcile Solaris' os::sleep with the linux variation. 3760 //
3793 // Solaris uses poll(), linux uses park(). 3761 // Short sleep, direct OS call.
3794 // Poll() is likely a better choice, assuming that Thread.interrupt() 3762 //
3795 // generates a SIGUSRx signal. Note that SIGUSR1 can interfere with 3763 // Note: certain versions of Linux CFS scheduler (since 2.6.23) do not guarantee
3796 // SIGSEGV, see 4355769. 3764 // sched_yield(2) will actually give up the CPU:
3797 3765 //
3798 int os::sleep(Thread* thread, jlong millis, bool interruptible) { 3766 // * Alone on this pariticular CPU, keeps running.
3799 assert(thread == Thread::current(), "thread consistency check"); 3767 // * Before the introduction of "skip_buddy" with "compat_yield" disabled
3800 3768 // (pre 2.6.39).
3801 ParkEvent * const slp = thread->_SleepEvent ; 3769 //
3802 slp->reset() ; 3770 // So calling this with 0 is an alternative.
3803 OrderAccess::fence() ; 3771 //
3804 3772 void os::naked_short_sleep(jlong ms) {
3805 if (interruptible) { 3773 struct timespec req;
3806 jlong prevtime = javaTimeNanos(); 3774
3807 3775 assert(ms < 1000, "Un-interruptable sleep, short time use only");
3808 for (;;) { 3776 req.tv_sec = 0;
3809 if (os::is_interrupted(thread, true)) { 3777 if (ms > 0) {
3810 return OS_INTRPT; 3778 req.tv_nsec = (ms % 1000) * 1000000;
3811 } 3779 }
3812 3780 else {
3813 jlong newtime = javaTimeNanos(); 3781 req.tv_nsec = 1;
3814 3782 }
3815 if (newtime - prevtime < 0) { 3783
3816 // time moving backwards, should only happen if no monotonic clock 3784 nanosleep(&req, NULL);
3817 // not a guarantee() because JVM should not abort on kernel/glibc bugs 3785
3818 assert(!Linux::supports_monotonic_clock(), "time moving backwards"); 3786 return;
3819 } else {
3820 millis -= (newtime - prevtime) / NANOSECS_PER_MILLISEC;
3821 }
3822
3823 if(millis <= 0) {
3824 return OS_OK;
3825 }
3826
3827 prevtime = newtime;
3828
3829 {
3830 assert(thread->is_Java_thread(), "sanity check");
3831 JavaThread *jt = (JavaThread *) thread;
3832 ThreadBlockInVM tbivm(jt);
3833 OSThreadWaitState osts(jt->osthread(), false /* not Object.wait() */);
3834
3835 jt->set_suspend_equivalent();
3836 // cleared by handle_special_suspend_equivalent_condition() or
3837 // java_suspend_self() via check_and_wait_while_suspended()
3838
3839 slp->park(millis);
3840
3841 // were we externally suspended while we were waiting?
3842 jt->check_and_wait_while_suspended();
3843 }
3844 }
3845 } else {
3846 OSThreadWaitState osts(thread->osthread(), false /* not Object.wait() */);
3847 jlong prevtime = javaTimeNanos();
3848
3849 for (;;) {
3850 // It'd be nice to avoid the back-to-back javaTimeNanos() calls on
3851 // the 1st iteration ...
3852 jlong newtime = javaTimeNanos();
3853
3854 if (newtime - prevtime < 0) {
3855 // time moving backwards, should only happen if no monotonic clock
3856 // not a guarantee() because JVM should not abort on kernel/glibc bugs
3857 assert(!Linux::supports_monotonic_clock(), "time moving backwards");
3858 } else {
3859 millis -= (newtime - prevtime) / NANOSECS_PER_MILLISEC;
3860 }
3861
3862 if(millis <= 0) break ;
3863
3864 prevtime = newtime;
3865 slp->park(millis);
3866 }
3867 return OS_OK ;
3868 }
3869 }
3870
3871 int os::naked_sleep() {
3872 // %% make the sleep time an integer flag. for now use 1 millisec.
3873 return os::sleep(Thread::current(), 1, false);
3874 } 3787 }
3875 3788
3876 // Sleep forever; naked call to OS-specific sleep; use with CAUTION 3789 // Sleep forever; naked call to OS-specific sleep; use with CAUTION
3877 void os::infinite_sleep() { 3790 void os::infinite_sleep() {
3878 while (true) { // sleep forever ... 3791 while (true) { // sleep forever ...
4192 ShouldNotReachHere(); 4105 ShouldNotReachHere();
4193 } 4106 }
4194 } 4107 }
4195 4108
4196 guarantee(osthread->sr.is_running(), "Must be running!"); 4109 guarantee(osthread->sr.is_running(), "Must be running!");
4197 }
4198
4199 ////////////////////////////////////////////////////////////////////////////////
4200 // interrupt support
4201
4202 void os::interrupt(Thread* thread) {
4203 assert(Thread::current() == thread || Threads_lock->owned_by_self(),
4204 "possibility of dangling Thread pointer");
4205
4206 OSThread* osthread = thread->osthread();
4207
4208 if (!osthread->interrupted()) {
4209 osthread->set_interrupted(true);
4210 // More than one thread can get here with the same value of osthread,
4211 // resulting in multiple notifications. We do, however, want the store
4212 // to interrupted() to be visible to other threads before we execute unpark().
4213 OrderAccess::fence();
4214 ParkEvent * const slp = thread->_SleepEvent ;
4215 if (slp != NULL) slp->unpark() ;
4216 }
4217
4218 // For JSR166. Unpark even if interrupt status already was set
4219 if (thread->is_Java_thread())
4220 ((JavaThread*)thread)->parker()->unpark();
4221
4222 ParkEvent * ev = thread->_ParkEvent ;
4223 if (ev != NULL) ev->unpark() ;
4224
4225 }
4226
4227 bool os::is_interrupted(Thread* thread, bool clear_interrupted) {
4228 assert(Thread::current() == thread || Threads_lock->owned_by_self(),
4229 "possibility of dangling Thread pointer");
4230
4231 OSThread* osthread = thread->osthread();
4232
4233 bool interrupted = osthread->interrupted();
4234
4235 if (interrupted && clear_interrupted) {
4236 osthread->set_interrupted(false);
4237 // consider thread->_SleepEvent->reset() ... optional optimization
4238 }
4239
4240 return interrupted;
4241 } 4110 }
4242 4111
4243 /////////////////////////////////////////////////////////////////////////////////// 4112 ///////////////////////////////////////////////////////////////////////////////////
4244 // signal handling (except suspend/resume) 4113 // signal handling (except suspend/resume)
4245 4114
4465 set_signal_handler(SIGSEGV, true); 4334 set_signal_handler(SIGSEGV, true);
4466 set_signal_handler(SIGPIPE, true); 4335 set_signal_handler(SIGPIPE, true);
4467 set_signal_handler(SIGBUS, true); 4336 set_signal_handler(SIGBUS, true);
4468 set_signal_handler(SIGILL, true); 4337 set_signal_handler(SIGILL, true);
4469 set_signal_handler(SIGFPE, true); 4338 set_signal_handler(SIGFPE, true);
4339 #if defined(PPC64)
4340 set_signal_handler(SIGTRAP, true);
4341 #endif
4470 set_signal_handler(SIGXFSZ, true); 4342 set_signal_handler(SIGXFSZ, true);
4471 4343
4472 if (libjsig_is_loaded) { 4344 if (libjsig_is_loaded) {
4473 // Tell libjsig jvm finishes setting signal handlers 4345 // Tell libjsig jvm finishes setting signal handlers
4474 (*end_signal_setting)(); 4346 (*end_signal_setting)();
4558 st->print("SIG_IGN"); 4430 st->print("SIG_IGN");
4559 } else { 4431 } else {
4560 st->print("[%s]", get_signal_handler_name(handler, buf, buflen)); 4432 st->print("[%s]", get_signal_handler_name(handler, buf, buflen));
4561 } 4433 }
4562 4434
4563 st->print(", sa_mask[0]=" PTR32_FORMAT, *(uint32_t*)&sa.sa_mask); 4435 st->print(", sa_mask[0]=");
4436 os::Posix::print_signal_set_short(st, &sa.sa_mask);
4564 4437
4565 address rh = VMError::get_resetted_sighandler(sig); 4438 address rh = VMError::get_resetted_sighandler(sig);
4566 // May be, handler was resetted by VMError? 4439 // May be, handler was resetted by VMError?
4567 if(rh != NULL) { 4440 if(rh != NULL) {
4568 handler = rh; 4441 handler = rh;
4569 sa.sa_flags = VMError::get_resetted_sigflags(sig) & SIGNIFICANT_SIGNAL_MASK; 4442 sa.sa_flags = VMError::get_resetted_sigflags(sig) & SIGNIFICANT_SIGNAL_MASK;
4570 } 4443 }
4571 4444
4572 st->print(", sa_flags=" PTR32_FORMAT, sa.sa_flags); 4445 st->print(", sa_flags=");
4446 os::Posix::print_sa_flags(st, sa.sa_flags);
4573 4447
4574 // Check: is it our handler? 4448 // Check: is it our handler?
4575 if(handler == CAST_FROM_FN_PTR(address, (sa_sigaction_t)signalHandler) || 4449 if(handler == CAST_FROM_FN_PTR(address, (sa_sigaction_t)signalHandler) ||
4576 handler == CAST_FROM_FN_PTR(address, (sa_sigaction_t)SR_handler)) { 4450 handler == CAST_FROM_FN_PTR(address, (sa_sigaction_t)SR_handler)) {
4577 // It is our signal handler 4451 // It is our signal handler
4605 DO_SIGNAL_CHECK(SIGILL); 4479 DO_SIGNAL_CHECK(SIGILL);
4606 DO_SIGNAL_CHECK(SIGFPE); 4480 DO_SIGNAL_CHECK(SIGFPE);
4607 DO_SIGNAL_CHECK(SIGBUS); 4481 DO_SIGNAL_CHECK(SIGBUS);
4608 DO_SIGNAL_CHECK(SIGPIPE); 4482 DO_SIGNAL_CHECK(SIGPIPE);
4609 DO_SIGNAL_CHECK(SIGXFSZ); 4483 DO_SIGNAL_CHECK(SIGXFSZ);
4610 4484 #if defined(PPC64)
4485 DO_SIGNAL_CHECK(SIGTRAP);
4486 #endif
4611 4487
4612 // ReduceSignalUsage allows the user to override these handlers 4488 // ReduceSignalUsage allows the user to override these handlers
4613 // see comments at the very top and jvm_solaris.h 4489 // see comments at the very top and jvm_solaris.h
4614 if (!ReduceSignalUsage) { 4490 if (!ReduceSignalUsage) {
4615 DO_SIGNAL_CHECK(SHUTDOWN1_SIGNAL); 4491 DO_SIGNAL_CHECK(SHUTDOWN1_SIGNAL);
4755 pthread_condattr_t* _condattr = os::Linux::condAttr(); 4631 pthread_condattr_t* _condattr = os::Linux::condAttr();
4756 if ((status = pthread_condattr_init(_condattr)) != 0) { 4632 if ((status = pthread_condattr_init(_condattr)) != 0) {
4757 fatal(err_msg("pthread_condattr_init: %s", strerror(status))); 4633 fatal(err_msg("pthread_condattr_init: %s", strerror(status)));
4758 } 4634 }
4759 // Only set the clock if CLOCK_MONOTONIC is available 4635 // Only set the clock if CLOCK_MONOTONIC is available
4760 if (Linux::supports_monotonic_clock()) { 4636 if (os::supports_monotonic_clock()) {
4761 if ((status = pthread_condattr_setclock(_condattr, CLOCK_MONOTONIC)) != 0) { 4637 if ((status = pthread_condattr_setclock(_condattr, CLOCK_MONOTONIC)) != 0) {
4762 if (status == EINVAL) { 4638 if (status == EINVAL) {
4763 warning("Unable to use monotonic clock with relative timed-waits" \ 4639 warning("Unable to use monotonic clock with relative timed-waits" \
4764 " - changes to the time-of-day clock may have adverse affects"); 4640 " - changes to the time-of-day clock may have adverse affects");
4765 } else { 4641 } else {
4927 4803
4928 // note: perfMemory_exit_helper atexit function may be removed in 4804 // note: perfMemory_exit_helper atexit function may be removed in
4929 // the future if the appropriate cleanup code can be added to the 4805 // the future if the appropriate cleanup code can be added to the
4930 // VM_Exit VMOperation's doit method. 4806 // VM_Exit VMOperation's doit method.
4931 if (atexit(perfMemory_exit_helper) != 0) { 4807 if (atexit(perfMemory_exit_helper) != 0) {
4932 warning("os::init2 atexit(perfMemory_exit_helper) failed"); 4808 warning("os::init_2 atexit(perfMemory_exit_helper) failed");
4933 } 4809 }
4934 } 4810 }
4935 4811
4936 // initialize thread priority policy 4812 // initialize thread priority policy
4937 prio_init(); 4813 prio_init();
4938 4814
4939 return JNI_OK; 4815 return JNI_OK;
4940 } 4816 }
4941 4817
4942 // this is called at the end of vm_initialization 4818 // this is called at the end of vm_initialization
4943 void os::init_3(void) 4819 void os::init_3(void) {
4944 {
4945 #ifdef JAVASE_EMBEDDED 4820 #ifdef JAVASE_EMBEDDED
4946 // Start the MemNotifyThread 4821 // Start the MemNotifyThread
4947 if (LowMemoryProtection) { 4822 if (LowMemoryProtection) {
4948 MemNotifyThread::start(); 4823 MemNotifyThread::start();
4949 } 4824 }
5586 millis %= 1000; 5461 millis %= 1000;
5587 if (seconds > 50000000) { // see man cond_timedwait(3T) 5462 if (seconds > 50000000) { // see man cond_timedwait(3T)
5588 seconds = 50000000; 5463 seconds = 50000000;
5589 } 5464 }
5590 5465
5591 if (os::Linux::supports_monotonic_clock()) { 5466 if (os::supports_monotonic_clock()) {
5592 struct timespec now; 5467 struct timespec now;
5593 int status = os::Linux::clock_gettime(CLOCK_MONOTONIC, &now); 5468 int status = os::Linux::clock_gettime(CLOCK_MONOTONIC, &now);
5594 assert_status(status == 0, status, "clock_gettime"); 5469 assert_status(status == 0, status, "clock_gettime");
5595 abstime->tv_sec = now.tv_sec + seconds; 5470 abstime->tv_sec = now.tv_sec + seconds;
5596 long nanos = now.tv_nsec + millis * NANOSECS_PER_MILLISEC; 5471 long nanos = now.tv_nsec + millis * NANOSECS_PER_MILLISEC;
5803 5678
5804 static void unpackTime(timespec* absTime, bool isAbsolute, jlong time) { 5679 static void unpackTime(timespec* absTime, bool isAbsolute, jlong time) {
5805 assert (time > 0, "convertTime"); 5680 assert (time > 0, "convertTime");
5806 time_t max_secs = 0; 5681 time_t max_secs = 0;
5807 5682
5808 if (!os::Linux::supports_monotonic_clock() || isAbsolute) { 5683 if (!os::supports_monotonic_clock() || isAbsolute) {
5809 struct timeval now; 5684 struct timeval now;
5810 int status = gettimeofday(&now, NULL); 5685 int status = gettimeofday(&now, NULL);
5811 assert(status == 0, "gettimeofday"); 5686 assert(status == 0, "gettimeofday");
5812 5687
5813 max_secs = now.tv_sec + MAX_SECS; 5688 max_secs = now.tv_sec + MAX_SECS;