comparison src/os/linux/vm/os_linux.cpp @ 14909:4ca6dc0799b6

Backout jdk9 merge
author Gilles Duboscq <duboscq@ssw.jku.at>
date Tue, 01 Apr 2014 13:57:07 +0200
parents d8041d695d19
children b1911c1e44c8
comparison
equal deleted inserted replaced
14908:8db6e76cb658 14909:4ca6dc0799b6
1 /* 1 /*
2 * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1999, 2013, 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(PPC32) 260 #elif defined(PPC)
261 static char cpu_arch[] = "ppc"; 261 static char cpu_arch[] = "ppc";
262 #elif defined(PPC64)
263 static char cpu_arch[] = "ppc64";
264 #elif defined(SPARC) 262 #elif defined(SPARC)
265 # ifdef _LP64 263 # ifdef _LP64
266 static char cpu_arch[] = "sparcv9"; 264 static char cpu_arch[] = "sparcv9";
267 # else 265 # else
268 static char cpu_arch[] = "sparc"; 266 static char cpu_arch[] = "sparc";
530 sigemptyset(&allowdebug_blocked_sigs); 528 sigemptyset(&allowdebug_blocked_sigs);
531 sigaddset(&unblocked_sigs, SIGILL); 529 sigaddset(&unblocked_sigs, SIGILL);
532 sigaddset(&unblocked_sigs, SIGSEGV); 530 sigaddset(&unblocked_sigs, SIGSEGV);
533 sigaddset(&unblocked_sigs, SIGBUS); 531 sigaddset(&unblocked_sigs, SIGBUS);
534 sigaddset(&unblocked_sigs, SIGFPE); 532 sigaddset(&unblocked_sigs, SIGFPE);
535 #if defined(PPC64)
536 sigaddset(&unblocked_sigs, SIGTRAP);
537 #endif
538 sigaddset(&unblocked_sigs, SR_signum); 533 sigaddset(&unblocked_sigs, SR_signum);
539 534
540 if (!ReduceSignalUsage) { 535 if (!ReduceSignalUsage) {
541 if (!os::Linux::is_sig_ignored(SHUTDOWN1_SIGNAL)) { 536 if (!os::Linux::is_sig_ignored(SHUTDOWN1_SIGNAL)) {
542 sigaddset(&unblocked_sigs, SHUTDOWN1_SIGNAL); 537 sigaddset(&unblocked_sigs, SHUTDOWN1_SIGNAL);
1454 _pthread_getcpuclockid = pthread_getcpuclockid_func; 1449 _pthread_getcpuclockid = pthread_getcpuclockid_func;
1455 } 1450 }
1456 } 1451 }
1457 1452
1458 jlong os::javaTimeNanos() { 1453 jlong os::javaTimeNanos() {
1459 if (os::supports_monotonic_clock()) { 1454 if (Linux::supports_monotonic_clock()) {
1460 struct timespec tp; 1455 struct timespec tp;
1461 int status = Linux::clock_gettime(CLOCK_MONOTONIC, &tp); 1456 int status = Linux::clock_gettime(CLOCK_MONOTONIC, &tp);
1462 assert(status == 0, "gettime error"); 1457 assert(status == 0, "gettime error");
1463 jlong result = jlong(tp.tv_sec) * (1000 * 1000 * 1000) + jlong(tp.tv_nsec); 1458 jlong result = jlong(tp.tv_sec) * (1000 * 1000 * 1000) + jlong(tp.tv_nsec);
1464 return result; 1459 return result;
1470 return 1000 * usecs; 1465 return 1000 * usecs;
1471 } 1466 }
1472 } 1467 }
1473 1468
1474 void os::javaTimeNanos_info(jvmtiTimerInfo *info_ptr) { 1469 void os::javaTimeNanos_info(jvmtiTimerInfo *info_ptr) {
1475 if (os::supports_monotonic_clock()) { 1470 if (Linux::supports_monotonic_clock()) {
1476 info_ptr->max_value = ALL_64_BITS; 1471 info_ptr->max_value = ALL_64_BITS;
1477 1472
1478 // CLOCK_MONOTONIC - amount of time since some arbitrary point in the past 1473 // CLOCK_MONOTONIC - amount of time since some arbitrary point in the past
1479 info_ptr->may_skip_backward = false; // not subject to resetting or drifting 1474 info_ptr->may_skip_backward = false; // not subject to resetting or drifting
1480 info_ptr->may_skip_forward = false; // not subject to resetting or drifting 1475 info_ptr->may_skip_forward = false; // not subject to resetting or drifting
2107 void* res = dlsym(handle, name); 2102 void* res = dlsym(handle, name);
2108 pthread_mutex_unlock(&dl_mutex); 2103 pthread_mutex_unlock(&dl_mutex);
2109 return res; 2104 return res;
2110 } 2105 }
2111 2106
2112 void* os::get_default_process_handle() {
2113 return (void*)::dlopen(NULL, RTLD_LAZY);
2114 }
2115 2107
2116 static bool _print_ascii_file(const char* filename, outputStream* st) { 2108 static bool _print_ascii_file(const char* filename, outputStream* st) {
2117 int fd = ::open(filename, O_RDONLY); 2109 int fd = ::open(filename, O_RDONLY);
2118 if (fd == -1) { 2110 if (fd == -1) {
2119 return false; 2111 return false;
2263 st->print(" <Not Available>"); 2255 st->print(" <Not Available>");
2264 } 2256 }
2265 st->cr(); 2257 st->cr();
2266 } 2258 }
2267 2259
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
2268 void os::print_siginfo(outputStream* st, void* siginfo) { 2275 void os::print_siginfo(outputStream* st, void* siginfo) {
2269 const siginfo_t* si = (const siginfo_t*)siginfo; 2276 st->print("siginfo:");
2270 2277
2271 os::Posix::print_siginfo_brief(st, si); 2278 const int buflen = 100;
2272 2279 char buf[buflen];
2273 if (si && (si->si_signo == SIGBUS || si->si_signo == SIGSEGV) && 2280 siginfo_t *si = (siginfo_t*)siginfo;
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) &&
2274 UseSharedSpaces) { 2312 UseSharedSpaces) {
2275 FileMapInfo* mapinfo = FileMapInfo::current_info(); 2313 FileMapInfo* mapinfo = FileMapInfo::current_info();
2276 if (mapinfo->is_in_shared_space(si->si_addr)) { 2314 if (mapinfo->is_in_shared_space(si->si_addr)) {
2277 st->print("\n\nError accessing class data sharing archive." \ 2315 st->print("\n\nError accessing class data sharing archive." \
2278 " Mapped file inaccessible during execution, " \ 2316 " Mapped file inaccessible during execution, " \
2298 print_signal_handler(st, SR_signum, buf, buflen); 2336 print_signal_handler(st, SR_signum, buf, buflen);
2299 print_signal_handler(st, SHUTDOWN1_SIGNAL, buf, buflen); 2337 print_signal_handler(st, SHUTDOWN1_SIGNAL, buf, buflen);
2300 print_signal_handler(st, SHUTDOWN2_SIGNAL , buf, buflen); 2338 print_signal_handler(st, SHUTDOWN2_SIGNAL , buf, buflen);
2301 print_signal_handler(st, SHUTDOWN3_SIGNAL , buf, buflen); 2339 print_signal_handler(st, SHUTDOWN3_SIGNAL , buf, buflen);
2302 print_signal_handler(st, BREAK_SIGNAL, buf, buflen); 2340 print_signal_handler(st, BREAK_SIGNAL, buf, buflen);
2303 #if defined(PPC64)
2304 print_signal_handler(st, SIGTRAP, buf, buflen);
2305 #endif
2306 } 2341 }
2307 2342
2308 static char saved_jvm_path[MAXPATHLEN] = {0}; 2343 static char saved_jvm_path[MAXPATHLEN] = {0};
2309 2344
2310 // Find the full path to the current module, libjvm.so 2345 // Find the full path to the current module, libjvm.so
2331 rp = realpath(dli_fname, buf); 2366 rp = realpath(dli_fname, buf);
2332 } 2367 }
2333 if (rp == NULL) 2368 if (rp == NULL)
2334 return; 2369 return;
2335 2370
2336 if (Arguments::sun_java_launcher_is_altjvm()) { 2371 if (Arguments::created_by_gamma_launcher()) {
2337 // Support for the java launcher's '-XXaltjvm=<path>' option. Typical 2372 // Support for the gamma launcher. Typical value for buf is
2338 // value for buf is "<JAVA_HOME>/jre/lib/<arch>/<vmtype>/libjvm.so". 2373 // "<JAVA_HOME>/jre/lib/<arch>/<vmtype>/libjvm.so". If "/jre/lib/" appears at
2339 // If "/jre/lib/" appears at the right place in the string, then 2374 // the right place in the string, then assume we are installed in a JDK and
2340 // assume we are installed in a JDK and we're done. Otherwise, check 2375 // we're done. Otherwise, check for a JAVA_HOME environment variable and fix
2341 // for a JAVA_HOME environment variable and fix up the path so it 2376 // up the path so it looks like libjvm.so is installed there (append a
2342 // looks like libjvm.so is installed there (append a fake suffix 2377 // fake suffix hotspot/libjvm.so).
2343 // hotspot/libjvm.so).
2344 const char *p = buf + strlen(buf) - 1; 2378 const char *p = buf + strlen(buf) - 1;
2345 for (int count = 0; p > buf && count < 5; ++count) { 2379 for (int count = 0; p > buf && count < 5; ++count) {
2346 for (--p; p > buf && *p != '/'; --p) 2380 for (--p; p > buf && *p != '/'; --p)
2347 /* empty */ ; 2381 /* empty */ ;
2348 } 2382 }
2960 size_t page_sz = os::vm_page_size(); 2994 size_t page_sz = os::vm_page_size();
2961 unsigned pages = size / page_sz; 2995 unsigned pages = size / page_sz;
2962 2996
2963 unsigned char vec[1]; 2997 unsigned char vec[1];
2964 unsigned imin = 1, imax = pages + 1, imid; 2998 unsigned imin = 1, imax = pages + 1, imid;
2965 int mincore_return_value = 0; 2999 int mincore_return_value;
2966
2967 assert(imin <= imax, "Unexpected page size");
2968 3000
2969 while (imin < imax) { 3001 while (imin < imax) {
2970 imid = (imax + imin) / 2; 3002 imid = (imax + imin) / 2;
2971 nbot = ntop - (imid * page_sz); 3003 nbot = ntop - (imid * page_sz);
2972 3004
3755 3787
3756 size_t os::read(int fd, void *buf, unsigned int nBytes) { 3788 size_t os::read(int fd, void *buf, unsigned int nBytes) {
3757 return ::read(fd, buf, nBytes); 3789 return ::read(fd, buf, nBytes);
3758 } 3790 }
3759 3791
3760 // 3792 // TODO-FIXME: reconcile Solaris' os::sleep with the linux variation.
3761 // Short sleep, direct OS call. 3793 // Solaris uses poll(), linux uses park().
3762 // 3794 // Poll() is likely a better choice, assuming that Thread.interrupt()
3763 // Note: certain versions of Linux CFS scheduler (since 2.6.23) do not guarantee 3795 // generates a SIGUSRx signal. Note that SIGUSR1 can interfere with
3764 // sched_yield(2) will actually give up the CPU: 3796 // SIGSEGV, see 4355769.
3765 // 3797
3766 // * Alone on this pariticular CPU, keeps running. 3798 int os::sleep(Thread* thread, jlong millis, bool interruptible) {
3767 // * Before the introduction of "skip_buddy" with "compat_yield" disabled 3799 assert(thread == Thread::current(), "thread consistency check");
3768 // (pre 2.6.39). 3800
3769 // 3801 ParkEvent * const slp = thread->_SleepEvent ;
3770 // So calling this with 0 is an alternative. 3802 slp->reset() ;
3771 // 3803 OrderAccess::fence() ;
3772 void os::naked_short_sleep(jlong ms) { 3804
3773 struct timespec req; 3805 if (interruptible) {
3774 3806 jlong prevtime = javaTimeNanos();
3775 assert(ms < 1000, "Un-interruptable sleep, short time use only"); 3807
3776 req.tv_sec = 0; 3808 for (;;) {
3777 if (ms > 0) { 3809 if (os::is_interrupted(thread, true)) {
3778 req.tv_nsec = (ms % 1000) * 1000000; 3810 return OS_INTRPT;
3779 } 3811 }
3780 else { 3812
3781 req.tv_nsec = 1; 3813 jlong newtime = javaTimeNanos();
3782 } 3814
3783 3815 if (newtime - prevtime < 0) {
3784 nanosleep(&req, NULL); 3816 // time moving backwards, should only happen if no monotonic clock
3785 3817 // not a guarantee() because JVM should not abort on kernel/glibc bugs
3786 return; 3818 assert(!Linux::supports_monotonic_clock(), "time moving backwards");
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);
3787 } 3874 }
3788 3875
3789 // Sleep forever; naked call to OS-specific sleep; use with CAUTION 3876 // Sleep forever; naked call to OS-specific sleep; use with CAUTION
3790 void os::infinite_sleep() { 3877 void os::infinite_sleep() {
3791 while (true) { // sleep forever ... 3878 while (true) { // sleep forever ...
4105 ShouldNotReachHere(); 4192 ShouldNotReachHere();
4106 } 4193 }
4107 } 4194 }
4108 4195
4109 guarantee(osthread->sr.is_running(), "Must be running!"); 4196 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;
4110 } 4241 }
4111 4242
4112 /////////////////////////////////////////////////////////////////////////////////// 4243 ///////////////////////////////////////////////////////////////////////////////////
4113 // signal handling (except suspend/resume) 4244 // signal handling (except suspend/resume)
4114 4245
4334 set_signal_handler(SIGSEGV, true); 4465 set_signal_handler(SIGSEGV, true);
4335 set_signal_handler(SIGPIPE, true); 4466 set_signal_handler(SIGPIPE, true);
4336 set_signal_handler(SIGBUS, true); 4467 set_signal_handler(SIGBUS, true);
4337 set_signal_handler(SIGILL, true); 4468 set_signal_handler(SIGILL, true);
4338 set_signal_handler(SIGFPE, true); 4469 set_signal_handler(SIGFPE, true);
4339 #if defined(PPC64)
4340 set_signal_handler(SIGTRAP, true);
4341 #endif
4342 set_signal_handler(SIGXFSZ, true); 4470 set_signal_handler(SIGXFSZ, true);
4343 4471
4344 if (libjsig_is_loaded) { 4472 if (libjsig_is_loaded) {
4345 // Tell libjsig jvm finishes setting signal handlers 4473 // Tell libjsig jvm finishes setting signal handlers
4346 (*end_signal_setting)(); 4474 (*end_signal_setting)();
4430 st->print("SIG_IGN"); 4558 st->print("SIG_IGN");
4431 } else { 4559 } else {
4432 st->print("[%s]", get_signal_handler_name(handler, buf, buflen)); 4560 st->print("[%s]", get_signal_handler_name(handler, buf, buflen));
4433 } 4561 }
4434 4562
4435 st->print(", sa_mask[0]="); 4563 st->print(", sa_mask[0]=" PTR32_FORMAT, *(uint32_t*)&sa.sa_mask);
4436 os::Posix::print_signal_set_short(st, &sa.sa_mask);
4437 4564
4438 address rh = VMError::get_resetted_sighandler(sig); 4565 address rh = VMError::get_resetted_sighandler(sig);
4439 // May be, handler was resetted by VMError? 4566 // May be, handler was resetted by VMError?
4440 if(rh != NULL) { 4567 if(rh != NULL) {
4441 handler = rh; 4568 handler = rh;
4442 sa.sa_flags = VMError::get_resetted_sigflags(sig) & SIGNIFICANT_SIGNAL_MASK; 4569 sa.sa_flags = VMError::get_resetted_sigflags(sig) & SIGNIFICANT_SIGNAL_MASK;
4443 } 4570 }
4444 4571
4445 st->print(", sa_flags="); 4572 st->print(", sa_flags=" PTR32_FORMAT, sa.sa_flags);
4446 os::Posix::print_sa_flags(st, sa.sa_flags);
4447 4573
4448 // Check: is it our handler? 4574 // Check: is it our handler?
4449 if(handler == CAST_FROM_FN_PTR(address, (sa_sigaction_t)signalHandler) || 4575 if(handler == CAST_FROM_FN_PTR(address, (sa_sigaction_t)signalHandler) ||
4450 handler == CAST_FROM_FN_PTR(address, (sa_sigaction_t)SR_handler)) { 4576 handler == CAST_FROM_FN_PTR(address, (sa_sigaction_t)SR_handler)) {
4451 // It is our signal handler 4577 // It is our signal handler
4479 DO_SIGNAL_CHECK(SIGILL); 4605 DO_SIGNAL_CHECK(SIGILL);
4480 DO_SIGNAL_CHECK(SIGFPE); 4606 DO_SIGNAL_CHECK(SIGFPE);
4481 DO_SIGNAL_CHECK(SIGBUS); 4607 DO_SIGNAL_CHECK(SIGBUS);
4482 DO_SIGNAL_CHECK(SIGPIPE); 4608 DO_SIGNAL_CHECK(SIGPIPE);
4483 DO_SIGNAL_CHECK(SIGXFSZ); 4609 DO_SIGNAL_CHECK(SIGXFSZ);
4484 #if defined(PPC64) 4610
4485 DO_SIGNAL_CHECK(SIGTRAP);
4486 #endif
4487 4611
4488 // ReduceSignalUsage allows the user to override these handlers 4612 // ReduceSignalUsage allows the user to override these handlers
4489 // see comments at the very top and jvm_solaris.h 4613 // see comments at the very top and jvm_solaris.h
4490 if (!ReduceSignalUsage) { 4614 if (!ReduceSignalUsage) {
4491 DO_SIGNAL_CHECK(SHUTDOWN1_SIGNAL); 4615 DO_SIGNAL_CHECK(SHUTDOWN1_SIGNAL);
4631 pthread_condattr_t* _condattr = os::Linux::condAttr(); 4755 pthread_condattr_t* _condattr = os::Linux::condAttr();
4632 if ((status = pthread_condattr_init(_condattr)) != 0) { 4756 if ((status = pthread_condattr_init(_condattr)) != 0) {
4633 fatal(err_msg("pthread_condattr_init: %s", strerror(status))); 4757 fatal(err_msg("pthread_condattr_init: %s", strerror(status)));
4634 } 4758 }
4635 // Only set the clock if CLOCK_MONOTONIC is available 4759 // Only set the clock if CLOCK_MONOTONIC is available
4636 if (os::supports_monotonic_clock()) { 4760 if (Linux::supports_monotonic_clock()) {
4637 if ((status = pthread_condattr_setclock(_condattr, CLOCK_MONOTONIC)) != 0) { 4761 if ((status = pthread_condattr_setclock(_condattr, CLOCK_MONOTONIC)) != 0) {
4638 if (status == EINVAL) { 4762 if (status == EINVAL) {
4639 warning("Unable to use monotonic clock with relative timed-waits" \ 4763 warning("Unable to use monotonic clock with relative timed-waits" \
4640 " - changes to the time-of-day clock may have adverse affects"); 4764 " - changes to the time-of-day clock may have adverse affects");
4641 } else { 4765 } else {
4803 4927
4804 // note: perfMemory_exit_helper atexit function may be removed in 4928 // note: perfMemory_exit_helper atexit function may be removed in
4805 // the future if the appropriate cleanup code can be added to the 4929 // the future if the appropriate cleanup code can be added to the
4806 // VM_Exit VMOperation's doit method. 4930 // VM_Exit VMOperation's doit method.
4807 if (atexit(perfMemory_exit_helper) != 0) { 4931 if (atexit(perfMemory_exit_helper) != 0) {
4808 warning("os::init_2 atexit(perfMemory_exit_helper) failed"); 4932 warning("os::init2 atexit(perfMemory_exit_helper) failed");
4809 } 4933 }
4810 } 4934 }
4811 4935
4812 // initialize thread priority policy 4936 // initialize thread priority policy
4813 prio_init(); 4937 prio_init();
4814 4938
4815 return JNI_OK; 4939 return JNI_OK;
4816 } 4940 }
4817 4941
4818 // this is called at the end of vm_initialization 4942 // this is called at the end of vm_initialization
4819 void os::init_3(void) { 4943 void os::init_3(void)
4944 {
4820 #ifdef JAVASE_EMBEDDED 4945 #ifdef JAVASE_EMBEDDED
4821 // Start the MemNotifyThread 4946 // Start the MemNotifyThread
4822 if (LowMemoryProtection) { 4947 if (LowMemoryProtection) {
4823 MemNotifyThread::start(); 4948 MemNotifyThread::start();
4824 } 4949 }
5461 millis %= 1000; 5586 millis %= 1000;
5462 if (seconds > 50000000) { // see man cond_timedwait(3T) 5587 if (seconds > 50000000) { // see man cond_timedwait(3T)
5463 seconds = 50000000; 5588 seconds = 50000000;
5464 } 5589 }
5465 5590
5466 if (os::supports_monotonic_clock()) { 5591 if (os::Linux::supports_monotonic_clock()) {
5467 struct timespec now; 5592 struct timespec now;
5468 int status = os::Linux::clock_gettime(CLOCK_MONOTONIC, &now); 5593 int status = os::Linux::clock_gettime(CLOCK_MONOTONIC, &now);
5469 assert_status(status == 0, status, "clock_gettime"); 5594 assert_status(status == 0, status, "clock_gettime");
5470 abstime->tv_sec = now.tv_sec + seconds; 5595 abstime->tv_sec = now.tv_sec + seconds;
5471 long nanos = now.tv_nsec + millis * NANOSECS_PER_MILLISEC; 5596 long nanos = now.tv_nsec + millis * NANOSECS_PER_MILLISEC;
5678 5803
5679 static void unpackTime(timespec* absTime, bool isAbsolute, jlong time) { 5804 static void unpackTime(timespec* absTime, bool isAbsolute, jlong time) {
5680 assert (time > 0, "convertTime"); 5805 assert (time > 0, "convertTime");
5681 time_t max_secs = 0; 5806 time_t max_secs = 0;
5682 5807
5683 if (!os::supports_monotonic_clock() || isAbsolute) { 5808 if (!os::Linux::supports_monotonic_clock() || isAbsolute) {
5684 struct timeval now; 5809 struct timeval now;
5685 int status = gettimeofday(&now, NULL); 5810 int status = gettimeofday(&now, NULL);
5686 assert(status == 0, "gettimeofday"); 5811 assert(status == 0, "gettimeofday");
5687 5812
5688 max_secs = now.tv_sec + MAX_SECS; 5813 max_secs = now.tv_sec + MAX_SECS;