< prev index next >

src/hotspot/os/bsd/os_bsd.cpp

Print this page
rev 56298 : 8231171: remove remaining sun.java.launcher.pid references


 119 // global variables
 120 julong os::Bsd::_physical_memory = 0;
 121 
 122 #ifdef __APPLE__
 123 mach_timebase_info_data_t os::Bsd::_timebase_info = {0, 0};
 124 volatile uint64_t         os::Bsd::_max_abstime   = 0;
 125 #else
 126 int (*os::Bsd::_clock_gettime)(clockid_t, struct timespec *) = NULL;
 127 #endif
 128 pthread_t os::Bsd::_main_thread;
 129 int os::Bsd::_page_size = -1;
 130 
 131 static jlong initial_time_count=0;
 132 
 133 static int clock_tics_per_sec = 100;
 134 
 135 // For diagnostics to print a message once. see run_periodic_checks
 136 static sigset_t check_signal_done;
 137 static bool check_signals = true;
 138 
 139 static pid_t _initial_pid = 0;
 140 
 141 // Signal number used to suspend/resume a thread
 142 
 143 // do not use any signal number less than SIGSEGV, see 4355769
 144 static int SR_signum = SIGUSR2;
 145 sigset_t SR_sigset;
 146 
 147 
 148 ////////////////////////////////////////////////////////////////////////////////
 149 // utility functions
 150 
 151 static int SR_initialize();
 152 
 153 julong os::available_memory() {
 154   return Bsd::available_memory();
 155 }
 156 
 157 // available here means free
 158 julong os::Bsd::available_memory() {
 159   uint64_t available = physical_memory() >> 2;
 160 #ifdef __APPLE__


1124 }
1125 
1126 int os::current_process_id() {
1127 
1128   // Under the old bsd thread library, bsd gives each thread
1129   // its own process id. Because of this each thread will return
1130   // a different pid if this method were to return the result
1131   // of getpid(2). Bsd provides no api that returns the pid
1132   // of the launcher thread for the vm. This implementation
1133   // returns a unique pid, the pid of the launcher thread
1134   // that starts the vm 'process'.
1135 
1136   // Under the NPTL, getpid() returns the same pid as the
1137   // launcher thread rather than a unique pid per thread.
1138   // Use gettid() if you want the old pre NPTL behaviour.
1139 
1140   // if you are looking for the result of a call to getpid() that
1141   // returns a unique pid for the calling thread, then look at the
1142   // OSThread::thread_id() method in osThread_bsd.hpp file
1143 
1144   return (int)(_initial_pid ? _initial_pid : getpid());
1145 }
1146 
1147 // DLL functions
1148 
1149 const char* os::dll_file_extension() { return JNI_LIB_SUFFIX; }
1150 
1151 // This must be hard coded because it's the system's temporary
1152 // directory not the java application's temp directory, ala java.io.tmpdir.
1153 #ifdef __APPLE__
1154 // macosx has a secure per-user temporary directory
1155 char temp_path_storage[PATH_MAX];
1156 const char* os::get_temp_directory() {
1157   static char *temp_path = NULL;
1158   if (temp_path == NULL) {
1159     int pathSize = confstr(_CS_DARWIN_USER_TEMP_DIR, temp_path_storage, PATH_MAX);
1160     if (pathSize == 0 || pathSize > PATH_MAX) {
1161       strlcpy(temp_path_storage, "/tmp/", sizeof(temp_path_storage));
1162     }
1163     temp_path = temp_path_storage;
1164   }


3069     tty->cr();
3070     tty->print("  found:");
3071     os::Posix::print_sa_flags(tty, act.sa_flags);
3072     tty->cr();
3073     // No need to check this sig any longer
3074     sigaddset(&check_signal_done, sig);
3075   }
3076 
3077   // Dump all the signal
3078   if (sigismember(&check_signal_done, sig)) {
3079     print_signal_handlers(tty, buf, O_BUFLEN);
3080   }
3081 }
3082 
3083 extern void report_error(char* file_name, int line_no, char* title,
3084                          char* format, ...);
3085 
3086 // this is called _before_ the most of global arguments have been parsed
3087 void os::init(void) {
3088   char dummy;   // used to get a guess on initial stack address
3089 
3090   // With BsdThreads the JavaMain thread pid (primordial thread)
3091   // is different than the pid of the java launcher thread.
3092   // So, on Bsd, the launcher thread pid is passed to the VM
3093   // via the sun.java.launcher.pid property.
3094   // Use this property instead of getpid() if it was correctly passed.
3095   // See bug 6351349.
3096   pid_t java_launcher_pid = (pid_t) Arguments::sun_java_launcher_pid();
3097 
3098   _initial_pid = (java_launcher_pid > 0) ? java_launcher_pid : getpid();
3099 
3100   clock_tics_per_sec = CLK_TCK;
3101 
3102   init_random(1234567);
3103 
3104   Bsd::set_page_size(getpagesize());
3105   if (Bsd::page_size() == -1) {
3106     fatal("os_bsd.cpp: os::init: sysconf failed (%s)", os::strerror(errno));
3107   }
3108   init_page_sizes((size_t) Bsd::page_size());
3109 
3110   Bsd::initialize_system_info();
3111 
3112   // _main_thread points to the thread that created/loaded the JVM.
3113   Bsd::_main_thread = pthread_self();
3114 
3115   Bsd::clock_init();
3116   initial_time_count = javaTimeNanos();
3117 
3118   os::Posix::init();




 119 // global variables
 120 julong os::Bsd::_physical_memory = 0;
 121 
 122 #ifdef __APPLE__
 123 mach_timebase_info_data_t os::Bsd::_timebase_info = {0, 0};
 124 volatile uint64_t         os::Bsd::_max_abstime   = 0;
 125 #else
 126 int (*os::Bsd::_clock_gettime)(clockid_t, struct timespec *) = NULL;
 127 #endif
 128 pthread_t os::Bsd::_main_thread;
 129 int os::Bsd::_page_size = -1;
 130 
 131 static jlong initial_time_count=0;
 132 
 133 static int clock_tics_per_sec = 100;
 134 
 135 // For diagnostics to print a message once. see run_periodic_checks
 136 static sigset_t check_signal_done;
 137 static bool check_signals = true;
 138 


 139 // Signal number used to suspend/resume a thread
 140 
 141 // do not use any signal number less than SIGSEGV, see 4355769
 142 static int SR_signum = SIGUSR2;
 143 sigset_t SR_sigset;
 144 
 145 
 146 ////////////////////////////////////////////////////////////////////////////////
 147 // utility functions
 148 
 149 static int SR_initialize();
 150 
 151 julong os::available_memory() {
 152   return Bsd::available_memory();
 153 }
 154 
 155 // available here means free
 156 julong os::Bsd::available_memory() {
 157   uint64_t available = physical_memory() >> 2;
 158 #ifdef __APPLE__


1122 }
1123 
1124 int os::current_process_id() {
1125 
1126   // Under the old bsd thread library, bsd gives each thread
1127   // its own process id. Because of this each thread will return
1128   // a different pid if this method were to return the result
1129   // of getpid(2). Bsd provides no api that returns the pid
1130   // of the launcher thread for the vm. This implementation
1131   // returns a unique pid, the pid of the launcher thread
1132   // that starts the vm 'process'.
1133 
1134   // Under the NPTL, getpid() returns the same pid as the
1135   // launcher thread rather than a unique pid per thread.
1136   // Use gettid() if you want the old pre NPTL behaviour.
1137 
1138   // if you are looking for the result of a call to getpid() that
1139   // returns a unique pid for the calling thread, then look at the
1140   // OSThread::thread_id() method in osThread_bsd.hpp file
1141 
1142   return (int)(getpid());
1143 }
1144 
1145 // DLL functions
1146 
1147 const char* os::dll_file_extension() { return JNI_LIB_SUFFIX; }
1148 
1149 // This must be hard coded because it's the system's temporary
1150 // directory not the java application's temp directory, ala java.io.tmpdir.
1151 #ifdef __APPLE__
1152 // macosx has a secure per-user temporary directory
1153 char temp_path_storage[PATH_MAX];
1154 const char* os::get_temp_directory() {
1155   static char *temp_path = NULL;
1156   if (temp_path == NULL) {
1157     int pathSize = confstr(_CS_DARWIN_USER_TEMP_DIR, temp_path_storage, PATH_MAX);
1158     if (pathSize == 0 || pathSize > PATH_MAX) {
1159       strlcpy(temp_path_storage, "/tmp/", sizeof(temp_path_storage));
1160     }
1161     temp_path = temp_path_storage;
1162   }


3067     tty->cr();
3068     tty->print("  found:");
3069     os::Posix::print_sa_flags(tty, act.sa_flags);
3070     tty->cr();
3071     // No need to check this sig any longer
3072     sigaddset(&check_signal_done, sig);
3073   }
3074 
3075   // Dump all the signal
3076   if (sigismember(&check_signal_done, sig)) {
3077     print_signal_handlers(tty, buf, O_BUFLEN);
3078   }
3079 }
3080 
3081 extern void report_error(char* file_name, int line_no, char* title,
3082                          char* format, ...);
3083 
3084 // this is called _before_ the most of global arguments have been parsed
3085 void os::init(void) {
3086   char dummy;   // used to get a guess on initial stack address










3087 
3088   clock_tics_per_sec = CLK_TCK;
3089 
3090   init_random(1234567);
3091 
3092   Bsd::set_page_size(getpagesize());
3093   if (Bsd::page_size() == -1) {
3094     fatal("os_bsd.cpp: os::init: sysconf failed (%s)", os::strerror(errno));
3095   }
3096   init_page_sizes((size_t) Bsd::page_size());
3097 
3098   Bsd::initialize_system_info();
3099 
3100   // _main_thread points to the thread that created/loaded the JVM.
3101   Bsd::_main_thread = pthread_self();
3102 
3103   Bsd::clock_init();
3104   initial_time_count = javaTimeNanos();
3105 
3106   os::Posix::init();


< prev index next >