< prev index next >

src/hotspot/os/solaris/os_solaris.cpp

Print this page




1009   // Store info on the Solaris thread into the OSThread
1010   osthread->set_thread_id(tid);
1011 
1012   // Remember that we created this thread so we can set priority on it
1013   osthread->set_vm_created();
1014 
1015   // Most thread types will set an explicit priority before starting the thread,
1016   // but for those that don't we need a valid value to read back in thread_native_entry.
1017   osthread->set_native_priority(NormPriority);
1018 
1019   // Initial thread state is INITIALIZED, not SUSPENDED
1020   osthread->set_state(INITIALIZED);
1021 
1022   // The thread is returned suspended (in state INITIALIZED), and is started higher up in the call chain
1023   return true;
1024 }
1025 
1026 debug_only(static bool signal_sets_initialized = false);
1027 static sigset_t unblocked_sigs, vm_sigs;
1028 
1029 bool os::Solaris::is_sig_ignored(int sig) {
1030   struct sigaction oact;
1031   sigaction(sig, (struct sigaction*)NULL, &oact);
1032   void* ohlr = oact.sa_sigaction ? CAST_FROM_FN_PTR(void*,  oact.sa_sigaction)
1033                                  : CAST_FROM_FN_PTR(void*,  oact.sa_handler);
1034   if (ohlr == CAST_FROM_FN_PTR(void*, SIG_IGN)) {
1035     return true;
1036   } else {
1037     return false;
1038   }
1039 }
1040 
1041 void os::Solaris::signal_sets_init() {
1042   // Should also have an assertion stating we are still single-threaded.
1043   assert(!signal_sets_initialized, "Already initialized");
1044   // Fill in signals that are necessarily unblocked for all threads in
1045   // the VM. Currently, we unblock the following signals:
1046   // SHUTDOWN{1,2,3}_SIGNAL: for shutdown hooks support (unless over-ridden
1047   //                         by -Xrs (=ReduceSignalUsage));
1048   // BREAK_SIGNAL which is unblocked only by the VM thread and blocked by all
1049   // other threads. The "ReduceSignalUsage" boolean tells us not to alter
1050   // the dispositions or masks wrt these signals.
1051   // Programs embedding the VM that want to use the above signals for their
1052   // own purposes must, at this time, use the "-Xrs" option to prevent
1053   // interference with shutdown hooks and BREAK_SIGNAL thread dumping.
1054   // (See bug 4345157, and other related bugs).
1055   // In reality, though, unblocking these signals is really a nop, since
1056   // these signals are not blocked by default.
1057   sigemptyset(&unblocked_sigs);
1058   sigaddset(&unblocked_sigs, SIGILL);
1059   sigaddset(&unblocked_sigs, SIGSEGV);
1060   sigaddset(&unblocked_sigs, SIGBUS);
1061   sigaddset(&unblocked_sigs, SIGFPE);
1062   sigaddset(&unblocked_sigs, ASYNC_SIGNAL);
1063 
1064   if (!ReduceSignalUsage) {
1065     if (!os::Solaris::is_sig_ignored(SHUTDOWN1_SIGNAL)) {
1066       sigaddset(&unblocked_sigs, SHUTDOWN1_SIGNAL);
1067     }
1068     if (!os::Solaris::is_sig_ignored(SHUTDOWN2_SIGNAL)) {
1069       sigaddset(&unblocked_sigs, SHUTDOWN2_SIGNAL);
1070     }
1071     if (!os::Solaris::is_sig_ignored(SHUTDOWN3_SIGNAL)) {
1072       sigaddset(&unblocked_sigs, SHUTDOWN3_SIGNAL);
1073     }
1074   }
1075   // Fill in signals that are blocked by all but the VM thread.
1076   sigemptyset(&vm_sigs);
1077   if (!ReduceSignalUsage) {
1078     sigaddset(&vm_sigs, BREAK_SIGNAL);
1079   }
1080   debug_only(signal_sets_initialized = true);
1081 
1082   // For diagnostics only used in run_periodic_checks
1083   sigemptyset(&check_signal_done);
1084 }
1085 
1086 // These are signals that are unblocked while a thread is running Java.
1087 // (For some reason, they get blocked by default.)
1088 sigset_t* os::Solaris::unblocked_signals() {
1089   assert(signal_sets_initialized, "Not initialized");
1090   return &unblocked_sigs;
1091 }




1009   // Store info on the Solaris thread into the OSThread
1010   osthread->set_thread_id(tid);
1011 
1012   // Remember that we created this thread so we can set priority on it
1013   osthread->set_vm_created();
1014 
1015   // Most thread types will set an explicit priority before starting the thread,
1016   // but for those that don't we need a valid value to read back in thread_native_entry.
1017   osthread->set_native_priority(NormPriority);
1018 
1019   // Initial thread state is INITIALIZED, not SUSPENDED
1020   osthread->set_state(INITIALIZED);
1021 
1022   // The thread is returned suspended (in state INITIALIZED), and is started higher up in the call chain
1023   return true;
1024 }
1025 
1026 debug_only(static bool signal_sets_initialized = false);
1027 static sigset_t unblocked_sigs, vm_sigs;
1028 












1029 void os::Solaris::signal_sets_init() {
1030   // Should also have an assertion stating we are still single-threaded.
1031   assert(!signal_sets_initialized, "Already initialized");
1032   // Fill in signals that are necessarily unblocked for all threads in
1033   // the VM. Currently, we unblock the following signals:
1034   // SHUTDOWN{1,2,3}_SIGNAL: for shutdown hooks support (unless over-ridden
1035   //                         by -Xrs (=ReduceSignalUsage));
1036   // BREAK_SIGNAL which is unblocked only by the VM thread and blocked by all
1037   // other threads. The "ReduceSignalUsage" boolean tells us not to alter
1038   // the dispositions or masks wrt these signals.
1039   // Programs embedding the VM that want to use the above signals for their
1040   // own purposes must, at this time, use the "-Xrs" option to prevent
1041   // interference with shutdown hooks and BREAK_SIGNAL thread dumping.
1042   // (See bug 4345157, and other related bugs).
1043   // In reality, though, unblocking these signals is really a nop, since
1044   // these signals are not blocked by default.
1045   sigemptyset(&unblocked_sigs);
1046   sigaddset(&unblocked_sigs, SIGILL);
1047   sigaddset(&unblocked_sigs, SIGSEGV);
1048   sigaddset(&unblocked_sigs, SIGBUS);
1049   sigaddset(&unblocked_sigs, SIGFPE);
1050   sigaddset(&unblocked_sigs, ASYNC_SIGNAL);
1051 
1052   if (!ReduceSignalUsage) {
1053     if (!os::Posix::is_sig_ignored(SHUTDOWN1_SIGNAL)) {
1054       sigaddset(&unblocked_sigs, SHUTDOWN1_SIGNAL);
1055     }
1056     if (!os::Posix::is_sig_ignored(SHUTDOWN2_SIGNAL)) {
1057       sigaddset(&unblocked_sigs, SHUTDOWN2_SIGNAL);
1058     }
1059     if (!os::Posix::is_sig_ignored(SHUTDOWN3_SIGNAL)) {
1060       sigaddset(&unblocked_sigs, SHUTDOWN3_SIGNAL);
1061     }
1062   }
1063   // Fill in signals that are blocked by all but the VM thread.
1064   sigemptyset(&vm_sigs);
1065   if (!ReduceSignalUsage) {
1066     sigaddset(&vm_sigs, BREAK_SIGNAL);
1067   }
1068   debug_only(signal_sets_initialized = true);
1069 
1070   // For diagnostics only used in run_periodic_checks
1071   sigemptyset(&check_signal_done);
1072 }
1073 
1074 // These are signals that are unblocked while a thread is running Java.
1075 // (For some reason, they get blocked by default.)
1076 sigset_t* os::Solaris::unblocked_signals() {
1077   assert(signal_sets_initialized, "Not initialized");
1078   return &unblocked_sigs;
1079 }


< prev index next >