< prev index next >

src/hotspot/os/aix/os_aix.cpp

Print this page




1793 }
1794 
1795 static void local_sem_wait() {
1796   static bool warn_only_once = false;
1797   if (os::Aix::on_aix()) {
1798     int rc = ::sem_wait(&sig_sem);
1799     if (rc == -1 && !warn_only_once) {
1800       trcVerbose("sem_wait failed (errno = %d, %s)", errno, os::errno_name(errno));
1801       warn_only_once = true;
1802     }
1803   } else {
1804     guarantee0(p_sig_msem != NULL); // must init before use
1805     int rc = ::msem_lock(p_sig_msem, 0);
1806     if (rc == -1 && !warn_only_once) {
1807       trcVerbose("msem_lock failed (errno = %d, %s)", errno, os::errno_name(errno));
1808       warn_only_once = true;
1809     }
1810   }
1811 }
1812 
1813 void os::signal_init_pd() {
1814   // Initialize signal structures
1815   ::memset((void*)pending_signals, 0, sizeof(pending_signals));
1816 
1817   // Initialize signal semaphore
1818   local_sem_init();
1819 }
1820 
1821 void os::signal_notify(int sig) {
1822   Atomic::inc(&pending_signals[sig]);
1823   local_sem_post();
1824 }
1825 
1826 static int check_pending_signals() {
1827   Atomic::store(0, &sigint_count);
1828   for (;;) {
1829     for (int i = 0; i < NSIG + 1; i++) {
1830       jint n = pending_signals[i];
1831       if (n > 0 && n == Atomic::cmpxchg(n - 1, &pending_signals[i], n)) {
1832         return i;
1833       }


3018   // pthread_sigmask returns error number, sigthreadmask -1 and sets global errno
3019   // (so, pthread_sigmask is more theadsafe for error handling)
3020   // But success is always 0.
3021   return rc == 0 ? true : false;
3022 }
3023 
3024 // Function to unblock all signals which are, according
3025 // to POSIX, typical program error signals. If they happen while being blocked,
3026 // they typically will bring down the process immediately.
3027 bool unblock_program_error_signals() {
3028   sigset_t set;
3029   ::sigemptyset(&set);
3030   ::sigaddset(&set, SIGILL);
3031   ::sigaddset(&set, SIGBUS);
3032   ::sigaddset(&set, SIGFPE);
3033   ::sigaddset(&set, SIGSEGV);
3034   return set_thread_signal_mask(SIG_UNBLOCK, &set, NULL);
3035 }
3036 
3037 // Renamed from 'signalHandler' to avoid collision with other shared libs.
3038 void javaSignalHandler(int sig, siginfo_t* info, void* uc) {
3039   assert(info != NULL && uc != NULL, "it must be old kernel");
3040 
3041   // Never leave program error signals blocked;
3042   // on all our platforms they would bring down the process immediately when
3043   // getting raised while being blocked.
3044   unblock_program_error_signals();
3045 
3046   int orig_errno = errno;  // Preserve errno value over signal handler.
3047   JVM_handle_aix_signal(sig, info, uc, true);
3048   errno = orig_errno;
3049 }
3050 
3051 // This boolean allows users to forward their own non-matching signals
3052 // to JVM_handle_aix_signal, harmlessly.
3053 bool os::Aix::signal_handlers_are_installed = false;
3054 
3055 // For signal-chaining
3056 struct sigaction sigact[NSIG];
3057 sigset_t sigs;
3058 bool os::Aix::libjsig_is_loaded = false;


3577   }
3578 
3579   trcVerbose("processor count: %d", os::_processor_count);
3580   trcVerbose("physical memory: %lu", Aix::_physical_memory);
3581 
3582   // Initially build up the loaded dll map.
3583   LoadedLibraries::reload();
3584   if (Verbose) {
3585     trcVerbose("Loaded Libraries: ");
3586     LoadedLibraries::print(tty);
3587   }
3588 
3589   // initialize suspend/resume support - must do this before signal_sets_init()
3590   if (SR_initialize() != 0) {
3591     perror("SR_initialize failed");
3592     return JNI_ERR;
3593   }
3594 
3595   Aix::signal_sets_init();
3596   Aix::install_signal_handlers();




3597 
3598   // Check and sets minimum stack sizes against command line options
3599   if (Posix::set_minimum_stack_sizes() == JNI_ERR) {
3600     return JNI_ERR;
3601   }
3602 
3603   if (UseNUMA) {
3604     UseNUMA = false;
3605     warning("NUMA optimizations are not available on this OS.");
3606   }
3607 
3608   if (MaxFDLimit) {
3609     // Set the number of file descriptors to max. print out error
3610     // if getrlimit/setrlimit fails but continue regardless.
3611     struct rlimit nbr_files;
3612     int status = getrlimit(RLIMIT_NOFILE, &nbr_files);
3613     if (status != 0) {
3614       log_info(os)("os::init_2 getrlimit failed: %s", os::strerror(errno));
3615     } else {
3616       nbr_files.rlim_cur = nbr_files.rlim_max;




1793 }
1794 
1795 static void local_sem_wait() {
1796   static bool warn_only_once = false;
1797   if (os::Aix::on_aix()) {
1798     int rc = ::sem_wait(&sig_sem);
1799     if (rc == -1 && !warn_only_once) {
1800       trcVerbose("sem_wait failed (errno = %d, %s)", errno, os::errno_name(errno));
1801       warn_only_once = true;
1802     }
1803   } else {
1804     guarantee0(p_sig_msem != NULL); // must init before use
1805     int rc = ::msem_lock(p_sig_msem, 0);
1806     if (rc == -1 && !warn_only_once) {
1807       trcVerbose("msem_lock failed (errno = %d, %s)", errno, os::errno_name(errno));
1808       warn_only_once = true;
1809     }
1810   }
1811 }
1812 
1813 static void jdk_misc_signal_init() {
1814   // Initialize signal structures
1815   ::memset((void*)pending_signals, 0, sizeof(pending_signals));
1816 
1817   // Initialize signal semaphore
1818   local_sem_init();
1819 }
1820 
1821 void os::signal_notify(int sig) {
1822   Atomic::inc(&pending_signals[sig]);
1823   local_sem_post();
1824 }
1825 
1826 static int check_pending_signals() {
1827   Atomic::store(0, &sigint_count);
1828   for (;;) {
1829     for (int i = 0; i < NSIG + 1; i++) {
1830       jint n = pending_signals[i];
1831       if (n > 0 && n == Atomic::cmpxchg(n - 1, &pending_signals[i], n)) {
1832         return i;
1833       }


3018   // pthread_sigmask returns error number, sigthreadmask -1 and sets global errno
3019   // (so, pthread_sigmask is more theadsafe for error handling)
3020   // But success is always 0.
3021   return rc == 0 ? true : false;
3022 }
3023 
3024 // Function to unblock all signals which are, according
3025 // to POSIX, typical program error signals. If they happen while being blocked,
3026 // they typically will bring down the process immediately.
3027 bool unblock_program_error_signals() {
3028   sigset_t set;
3029   ::sigemptyset(&set);
3030   ::sigaddset(&set, SIGILL);
3031   ::sigaddset(&set, SIGBUS);
3032   ::sigaddset(&set, SIGFPE);
3033   ::sigaddset(&set, SIGSEGV);
3034   return set_thread_signal_mask(SIG_UNBLOCK, &set, NULL);
3035 }
3036 
3037 // Renamed from 'signalHandler' to avoid collision with other shared libs.
3038 static void javaSignalHandler(int sig, siginfo_t* info, void* uc) {
3039   assert(info != NULL && uc != NULL, "it must be old kernel");
3040 
3041   // Never leave program error signals blocked;
3042   // on all our platforms they would bring down the process immediately when
3043   // getting raised while being blocked.
3044   unblock_program_error_signals();
3045 
3046   int orig_errno = errno;  // Preserve errno value over signal handler.
3047   JVM_handle_aix_signal(sig, info, uc, true);
3048   errno = orig_errno;
3049 }
3050 
3051 // This boolean allows users to forward their own non-matching signals
3052 // to JVM_handle_aix_signal, harmlessly.
3053 bool os::Aix::signal_handlers_are_installed = false;
3054 
3055 // For signal-chaining
3056 struct sigaction sigact[NSIG];
3057 sigset_t sigs;
3058 bool os::Aix::libjsig_is_loaded = false;


3577   }
3578 
3579   trcVerbose("processor count: %d", os::_processor_count);
3580   trcVerbose("physical memory: %lu", Aix::_physical_memory);
3581 
3582   // Initially build up the loaded dll map.
3583   LoadedLibraries::reload();
3584   if (Verbose) {
3585     trcVerbose("Loaded Libraries: ");
3586     LoadedLibraries::print(tty);
3587   }
3588 
3589   // initialize suspend/resume support - must do this before signal_sets_init()
3590   if (SR_initialize() != 0) {
3591     perror("SR_initialize failed");
3592     return JNI_ERR;
3593   }
3594 
3595   Aix::signal_sets_init();
3596   Aix::install_signal_handlers();
3597   // Initialize data for jdk.internal.misc.Signal
3598   if (!ReduceSignalUsage) {
3599     jdk_misc_signal_init();
3600   }
3601 
3602   // Check and sets minimum stack sizes against command line options
3603   if (Posix::set_minimum_stack_sizes() == JNI_ERR) {
3604     return JNI_ERR;
3605   }
3606 
3607   if (UseNUMA) {
3608     UseNUMA = false;
3609     warning("NUMA optimizations are not available on this OS.");
3610   }
3611 
3612   if (MaxFDLimit) {
3613     // Set the number of file descriptors to max. print out error
3614     // if getrlimit/setrlimit fails but continue regardless.
3615     struct rlimit nbr_files;
3616     int status = getrlimit(RLIMIT_NOFILE, &nbr_files);
3617     if (status != 0) {
3618       log_info(os)("os::init_2 getrlimit failed: %s", os::strerror(errno));
3619     } else {
3620       nbr_files.rlim_cur = nbr_files.rlim_max;


< prev index next >